HojunChoi / digitalwritefast

Automatically exported from code.google.com/p/digitalwritefast
0 stars 0 forks source link

optimized code doesn't use cbi / sbi #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
#define sclk 52
      digitalWriteFast(sclk, HIGH);
    12c6:   85 b1          in   r24, 0x05   ; 5
    12c8:   82 60          ori   r24, 0x02   ; 2
        asm volatile("nop \n\tnop \n\t");
    12ca:   00 00          nop
    12cc:   00 00          nop
      digitalWriteFast(sclk, LOW);   
    12ce:   8d 7f          andi   r24, 0xFD   ; 253
    12d0:   85 b9          out   0x05, r24   ; 5

after much research, this issue is that the __atomicWrite__ function is missing 
volatile casts on the first parameter to bitWrite which is causing the compiler 
to do various optimizations.  

Attached is a correct version of the code.  I've removed the (uint8_t*) casts 
in the digital macros and just placed them in the atomicWrite macro

Original issue reported on code.google.com by cr...@moonrock.com on 4 Aug 2011 at 6:08

Attachments:

GoogleCodeExporter commented 8 years ago
More information available here...
http://arduino.cc/forum/index.php/topic,68372.msg503964.html#msg503964

Original comment by arduino....@gmail.com on 5 Aug 2011 at 1:00