2009-05-28 06:25 PM
global interrupt enable
2011-05-17 04:12 AM
I found the macros __enable_irq() and __disable_irq() to set/clear the I-flag in PSR.
How can I read the I-flag from C-language to do something like the following?Code:
{
int IFlagTemp; IFlagTemp = __read_irq(); //this is the NEW function I need! __disable_irq(); //disable all IRQ's [my code] //my code, NEVER interrupted by any IRQ if(IFlagTemp) //re-enable IRQ's if necessary __enable_irq(); }2011-05-17 04:12 AM
Quote:
The device driver library you are using might might already have a function called __get_PRIMASK(void).
Thank you - this was exactly what I was looking for. I searched for a flag like IEN or GIEN but did not expect a whole register. Thank you!2011-05-17 04:12 AM
I'm pretty new at the STM32, and to C too, but I think it needs to be pointed out that the chips have a LOT of built in IO processing functionality, and you shouldn't have to do that task on most applications.
Stuff like the dallas touch button ''1 wire'' interface, you are better to do with interrupts, and queue a timer interrupt for when you need to update a transition, or to capture an edge.2011-05-17 04:12 AM
Unlike the ARM7TDMI, the Cortex-M3 processor do not have I-flag in the PSR, the interrupt enable and disable is controller by a register called PRIMASK. The device driver library you are using might might already have a function called __get_PRIMASK(void).
If not, you can find it in the CMSIS (Cortex Microcontroller Software Interface Standard) from www.onarm.com. Download the CMSIS, in the zipped file you can find a file Core\CM3\core_cm3.h The function __get_PRIMASK(void) is what you want. (The CMSIS supports multiple tools vendors so there are several implementations of the same function.)