Page 1 of 1

Interrupts - How to disable them??

Posted: Mon Jan 17, 2011 2:59 pm
by bspranger
Hi,
I was wondering what the best way is to disable interrupts when using ChiBios. I have a colleague that is trying to do a few things, and has had troubles.

This is for the STM32F2xx family of processors...

1. How do you disable ALL interrupts?

2. How do you disable only certain interrupts?

3. How do you disable the scheduler?

Thanks!

Brian

Re: Interrupts - How to disable them??

Posted: Mon Jan 17, 2011 3:39 pm
by Giovanni
In ChibiOS/RT there are three (abstract) levels of interrupt masking:

  • Normal, all interrupts enabled, chSysEnable() selects this state, this is the normal execution state where the OS is scheduling normally.
  • Suspend, only normal interrupts disabled, fast interrupts still working, chSysSuspend() selects this state, scheduling is suspended but fast interrupts can still preempt you..
  • Disabled, all interrupt sources except NMIs disabled, chSysDisable() selects this state.

You must not invoke any system API from within Suspend and Disabled states, if you need to invoke system APIs while keeping the interrupts disabled (and this is very common) then you need to use chSysLock()/chSysUnlock() which are semantically different from chSysEnable() and chSysSuspend() even if the implementation could be equal on some architectures. Please refer to the "System States" diagram present in the various kernel reference manuals, the diagram should explain all the various possible transitions.

If you need to disable only certain interrupt sources then you must act at the IRQ controller level, using the NVIC helper functions for example.

If you give more info about what you are trying to implement I could be more specific in my suggestions.

Giovanni