Hello, I have take a piece of source at http://www.arm.com and tried to compile it using the CARM compiler. The code is shown below:
/* NewState=1 will enable IRQ, NewState=0 will disable IRQ */ /* ARM core must be in a privileged mode, e.g. supervisor */ void ChangeIRQ(unsigned int NewState) { int my_cpsr; __asm { MRS my_cpsr, CPSR /* get current program status */ ORR my_cpsr, my_cpsr,#0x80 /* set IRQ disable bit flag */ BIC my_cpsr, my_cpsr, NewState, LSL #7 /* reset IRQ bit with new value */ MSR CPSR_c, my_cpsr /* store updated program status */ } } void main(void) { __asm{MSR CPSR_c, #0x13} //Go into Supervisor Mode ChangeIRQ(0); while(1) { } }
Actually you can find information about this also in our support knowledgebase: http://www.keil.com/support/docs/2991.htm In most cases, just enter the error number to get a related answer on the search field of http://www.keil.com/support. Reinhard
Peter, I tried to compile the piece of source and it went well, but it doesn't seem to have any effect. If I try to send something via the UART using THRE interrupt and I call the ChangeIrq(1); inside main, it just keeps sending via the UART. I should mean, that when global IRQ is disabled, the UART shouldn't send any more, when it needs THRE to send the next char.
Sorry, but what you are asking seems to be out of context. Take a look to: http://www.keil.com/download/docs/lpc2100_intsio.zip.asp Maybe this is the solution of your problem. Reinhard
ok, so where should I place the question if I just want to know how to disable global interrupts so I don't get disturbed by: timer, uart and external interrupts, while writing changes to an table and using the CARM compiler?
For this we have implemented __swi functions. Take a look to: http://www.keil.com/support/docs/2990.htm Reinhard
Thanks, so you mean that I can just use the __swi and write to my table inside this function and then I will not get interrupted by any IRQ!
YES