[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Failing to share a flag between two files/modules :-/

From: Parthasaradhi Nayani
Subject: Re: [avr-gcc-list] Failing to share a flag between two files/modules :-/
Date: Sun, 8 Feb 2009 08:35:46 -0800 (PST)

I guess there are two variables named "flag" being created, one in main and the other in ui.c. Please define the global variable in one .C file of your choice and tell the other file by using "extern" directive. Hope this solves your problem


--- On Sun, 2/8/09, Vincent Trouilliez <address@hidden> wrote:
From: Vincent Trouilliez <address@hidden>
Subject: [avr-gcc-list] Failing to share a flag between two files/modules :-/
To: "address@hidden" <address@hidden>
Date: Sunday, February 8, 2009, 2:02 PM

Hello Gents,

I am having problem communicating between main.c and another
file/module, ui.c to name it.

In main.c I set a flag from a timer ISR, every 100ms.
In ui.c I am watching for that flag, but unfortunately it always
reads zero :-/ However if I watch for the flag in main() then it works

I am watching the flag in ui.c, so I declared it in ui.h, then ui.h
gets included in main.c so I can set the flag from there.
Well that was my reasoning, but doesn't quite work sadly !

I must be doing something wrong obviously, just would love to learn what
it is ! ;-)


Vince, a bit stuck and wondering again...

static volatile uint8_t flag;


if( flag )
flag = 0;
/* Do some stuff */

#include "ui.h"

flag = 1;

main() {}

AVR-GCC-list mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]