Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] AvrStudio4 (2008), WinAVR (2007-05...) and Dragon problem debugging C code (jtag)

2008-06-09 by David Kelly

On Jun 8, 2008, at 7:00 PM, Cat Hotmail wrote:

> I'm not sure of all that "volatile" does (I know I need it for  
> variables
> that I use both in interrupts and out).


Volatile informs the compiler that the object may change between the  
compiler's uses. Therefore the compiler has to read it immediately  
before use if its value is needed. That it can't trust a copy of the  
variable laying around in a register. And when changing the value it  
must write it out immediately. And not merge the access across  
multiple statements.

If you say:

	volatile uint8_t v;

	v = 1;
	v = 0;
	v = 1;

the compiler is not allowed to notice the end result is v = 1 and skip  
the v = 0 step. With full optimization it just might skip those other  
steps. Thats why I asked if it was performing the skipped lines that  
you could not single-step debug.

--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

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.