Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: Help: volatile variable versus volatile array for ISR access

2007-11-03 by Graham Davies

--- In AVR-Chat@yahoogroups.com, "Cat C" <catalin_cluj@...> wrote:

> ... It works fine if I declare like this:
> volatile uint8_t iCh1 = 0, iCh2 = 0, ...
> but not if I change them to an array ... 
> volatile uint8_t iCh[6] = {0, 0, 0, 0, 0, 0};
> ... what can I do?

Try building up the type using consecutive typedefs.  Start by creating 
a type for a volatile variant of uint8_t, perhaps:
typedef volatile uint8_t vuint8_t;
and then define an array of those:
vuint8_t iCh[6] = {0, 0, 0, 0, 0, 0};

At least this way you can be sure that volatile "sticks" to the right 
part of the type.  Maybe report back if this makes a difference?

Graham.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.