atmoic read/write, RAM variables

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe that the AVR has no 16 bit read or write instruction. If so, then to read or write a RAM variable larager than a byte which can be altered by an interrupt routine, one needs an atomic access method. If there indeed is no 16 bit read/write, I guess you have to surround such an access at the application level with cli() and sei() or in more detail, the bit for the potentially impacting interrupt source.

The compiler does have an atomic read/write for 16 bit I/O registers.

Perhaps I've overlooked something that's in the compiler macros.

My misbehaving code is behaving now, after (duuuuuuuuh!) making accessses atomic.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

(excuse the previous typos)

I believe that the AVR has no 16 bit read or write instruction. If so, then to read or write a RAM variable larger than a byte which can be altered by an interrupt routine, one needs an atomic access method. If there indeed is no 16 bit AVR read/write, I guess you have to surround such an access at the application level with cli() and sei() or in more detail, the bit for the potentially impacting interrupt source.

The compiler does have an atomic read/write for 16 bit I/O registers.

Perhaps I've overlooked something that's in the compiler macros.

My misbehaving code is behaving now, after (duuuuuuuuh!) making accessses atomic

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, you are right. I had exaxtly the same problem this night. Yes, and I'm also thinking about a macro/define for such an atomic variable copying.

Regards
Olaf

admin's test signature