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) ;
If I'm not mistaken, the atomic library routine will give you what you want and would be a simpler implementation.
http://www.keil.com/support/man/docs/c166/c166__atomic_.htm