CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Updating An Array Element

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

Updating An Array Element
PostPosted: Wed Sep 01, 2010 4:47 am     Reply with quote

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: 19260

View user's profile Send private message

PostPosted: Wed Sep 01, 2010 5:02 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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