This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Does __disable_irq disable systick as well?

I'm using Keil uVision5 and an LPC1768 on an MCB1700 dev board.

I am writing a simple RTOS, and I have implemented two methods of context switching - one co-operative using a yield() function and one pre-emptive using SysTick. I just spent a while debugging a hardfault and long story short the SysTick context switcher would periodically fire in the middle of a cooperative context switch, which messed up my various stacks and led to the hard fault.

I have tried using __disable_irq() at the top of my yield function then re-enabling IRQ just before I do the switch (which happens in handler mode for various reasons), but that didn't fix anything. I have currently kludged together a solution where I have a global boolean that the yield function sets to false while it's doing its thing. If that boolean is false, the SysTick switcher just returns. 

I would like to disable the SysTick interrupt during a yield, but it seems that __disable_irq isn't the way to do it. Does anyone have any suggestions?