Millis Function in Due

I suspect an XY problem.

However, you can selectively block interrupts with priority number higher or equal to a prefixed number set with the priority group and the NVIC_SetPriority() CMSIS function.

Beware: Priority groups, Priority levels of interrupt handlers, premption and subpriority are a bit tricky.

millis() uses a tickcount activated by SysTick_Handler(). If you want to stop SysTick_Handler() from running in background, you have to:

  • Give a low prirority to SysTick_Handler()
  • Set BasePri to a higher urgency level (i.e. a lower number) as SysTick_Handler()

Here is an example sketch :

void setup() {
  Serial.begin(250000);
  /* Set SysTick interrupt preemption priority to 3 */
  NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 3, 0));

  /*
    If you want to selectively block interrupts with priority number higher or equal to 3,
    you could use the following code:and the NVIC_SetPriority() CMSIS function.
  */
  __set_BASEPRI(3 << (8 - __NVIC_PRIO_BITS));  // priority shifted left !!


}


void loop() {

  Serial.println(millis());  // millis() will not change anymore
  for (uint64_t i; i < 0xFFFFFFFFFFFFFF; i++);
}