We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, I check the assembly and I think that the call to
interrupt_safe_assign_ulong
(see below) is indeed interrupt safe but I am not sure (I am refering to the use of the static variable 's_long' as a parameter). Can you help me?
Thanks in advance
static unsigned long s_long ; void store_and_disable_interrupts(unsigned short *a_interrupts) { *a_interrupts = IEN ; IEN = 0 ; } void restore_interrupts(unsigned short a_interrupts) { IEN = a_interrupts ; } void interrupt_safe_assign_ulong(unsigned long *a_target, const unsigned long *a_source) { unsigned short l_interrupts ; store_and_disable_interrupts(&l_interrupts) ; *a_target = *a_source ; restore_interrupts(l_interrupts) ; } . . . interrupt_safe_assign_ulong(&l_long, &s_long) ;
You can help the compiler a bit by inlining your interrupt enable/disable code.
I don't work with the C166, but I recommend a quick peek at the generated code if you send the source as a pointer or as a value.
People, Thanks a lot. I didn't use _atomic_ because my C166 compiler does not support it! I think this implementation will do for now, will make it inline though. thanks again.
Just a comment if you use inline, you should add two NOP's after disabling interrupts to allow for pipeline delays on the C167.
You can find more information here: http://www.keil.com/support/man/docs/c166/c166_xf_interrupts.htm