|
|
View previous topic :: View next topic |
Author |
Message |
Geps
Joined: 05 Jul 2010 Posts: 129
|
Updating An Array Element |
Posted: Wed Sep 01, 2010 4:47 am |
|
|
Hi,
I have an array as declared:
Code: |
int16 Values[10] = {0,0,0,0,0,0,0,0,0,0};
int8 ValuesOverflow[10] = {0,0,0,0,0,0,0,0,0,0}; |
In my main functions I have:
Code: |
Values[SampleNumber] = get_timer0();
ValuesOverflow[SampleNumber] = 0b1;
ValuesOverflow[SampleNumber] = CurrentTimer0OverflowCount; |
Values() updates with the Timer0 Value however ValuesOverflow doesn't.
I've tried both the above lines and having stepped through the code it stays at 0,0,0,0,0,0,0,0,0,0.
PIC18F4520, using ICD-U64 and compiler 4.087
Cheers, |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Sep 01, 2010 5:02 am |
|
|
Obviously, if 'CurrentTimer0OverflowCount' is zero, then the value would stay 0.....
Prove what is happening, with something 'self testing', like:
Code: |
ValuesOverflow[SampleNumber] = SampleNumber;
|
If it stays zero, verify that you don't have something in (say) an interrupt handler clearing the value.
Also query 'where' these are declared, and what is immediately in front of them. So (for example), remember that if these are declared in a subroutine, the values are only 'kept' while you are in the routine. When you leave, they may be overwritten. If you have (say) an array used as a string in front of this array in the declarations, ask yourself if there is any possibility that this is overflowing?.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|