Besides declaring it as volatile, I would add disable/reenable
interrupts code around writing/reading. The reason is that being the
variable a 64 value reads and writes are two-step operations,
therefore there is no guarantee that you won't get an interrupt in
the middle of a write/read.
Guille
--- In lpc2000@yahoogroups.com, "charlesgrenz" <charles.grenz@...>
wrote:
>
> Do you have the variable as "volatile"?
>
> regards,
> Charles
>
> -- In lpc2000@yahoogroups.com, "lpc2131makingcl" <mking@> wrote:
> >
> > To Whom It May Concern:
> > I've been having problems with a variable of type "long long"
> > reading back an incorrect value. I'm using 2 external interrupts
to
> > generate binary data (0's and 1's). That data gets saved to a
> > variable which when read back is incorrect unless a while loop
with
> > a considerable delay time is inserted before accessing the
variable.
> >
> > Suggested has been to use an ISR "wrapper" in which you call a
> > function from an ISR. Tried that; did not help. Could the "long
> > long" data type be an issue? Code is as follows; card_data is
> > incorrect when trying to read it at statement store_card_data =...
> > By the way, the following is part of main() routine, not called
from
> > an ISR.
> >
> > void process_Card()
> > {
> > if(card_bits == 26)
> > {
> > store_card_data = ((card_data & 0xFFFFFFC000000000) >> 38);
> > site_code = (char)((store_card_data & 0x0000000001FE0000) >> 17);
> > card_num = (long long)((store_card_data & 0x000000000001FFFE) >>
1);
> > }
> >
> > else if(card_bits == 37)
> > {
> > store_card_data = card_data;
> > }
> >
> > card_data = 0;
> > card_bits = 0;
> > }
> >
>Message
Re: Temorarilry corrupted variable LPC2131 GNU Compiler
2006-02-09 by Guillermo Prandi
Attachments
- No local attachments were found for this message.