This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

disable interrupt for about 3 cycle

I need to turn on and off one pin around every 100 us. Time between must be 1 cycle (couple of ns) and can't be interrupted at any circumstances. Without a softdevice I disable interrupts like this:

__disable_irq();            
GPIO_PIN_ON;
__NOP();
GPIO_PIN_OFF;				    			    
__enable_irq();	

Must I use some other method when I will be using softdevice? The exact frequency is not so important but the pin can't be left turned on for more then one cycle.

Parents
  • disabling global interrupts that frequently is a problem. The softdevice have housekeeping timers running at the highest priority. If it misses this time, then it will assert. Even tough you are disabling global interrupts for less than 10 cpu cycles it might trigger a situation where you disabled it few cycles before the softdevice housekeeping timer interrupt is triggered and when you enable it it might see that it is few rtc ticks delayed. Softdevice will not accept this and assert because it know that it cannot happen and something went wrong.

    In other words you cannot guarantee that your pin will stay high only for once cycle when using softdevice when you do it so frequently.

    If you wanted to do this say once in few milliseconds, then we can take the risk of disabling all interrupts when using softdevice and hope that the above mentioned case is not hit. I mean by reducing the frequency of your pin toggles, you are reducing the probability of hitting the above mentioned scenario. So it is risk that you should decide to take or not.

  • So should I use a timeslots API? What if I ignore Softdevice assert?

Reply Children
No Data
Related