Hi,

> There is every reason. The flags get updated in interrupt routines and
> in non-interrupt code.
> 
>> Try the following version of set_status:
>>
>> void set_status(uint32_t flag, uint8_t set) {
>>      if (set) *(uint32_t* &status) |= flag;
>>      else *(uint32_t* &status) &= ~flag;
>>      asm("" : : : "memory");
>> }
>>
>> First, we remove the "volatile" from status so that the optimiser can  
>> give you a single byte access when the function is inlined.  Secondly,  
>> instead of using "volatile" to protect the access to "status", we use a  
>> memory clobber that forces writes to memory variables to be completed  
>> before going on.  This will ensure that the change is written out to  
>> status as soon as possible (otherwise changes could be cached for later  
>> storage).
>>
> 
> Which would be a problem, since the volatile nature of the variable is
> important in this usage.

Why? The memory clobber does exactly what you need for using it in an
interrupt and outside.

-Alex


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to