Interrupts - How to disable them??

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
bspranger
Posts: 8
Joined: Wed Dec 22, 2010 9:16 pm

Interrupts - How to disable them??

Post 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
Last edited by bspranger on Mon Jan 17, 2011 3:39 pm, edited 1 time in total.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Interrupts - How to disable them??

Post 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
Post Reply