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 CCS Technical Support

I just don't get it ?? Data Table Question Please

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



Joined: 07 Sep 2008
Posts: 2
Location: Alabama

View user's profile Send private message

I just don't get it ?? Data Table Question Please
PostPosted: Wed Mar 17, 2010 1:06 pm     Reply with quote

Hi folks
I'm a "use it every now and then " with the CCS compiler and seems I always run into something that completely baffles me. This an example.

I want to make a small data table to hold a few float32 numbers like so:
Code:

float32 const band [3]= {3000000, 4000000,5000000};
float32 myfreq;
int i=0;
i = 1;
myfreq = band[i];

printf does not show 4000000 and the number is not even close but consistant.

But if I use :
Code:
myfreq = band[1];

instead of
Code:
 myfreq = band[i];

printf shows 4000000.

If I make the data table like this:
Code:

float32 band []= {3000000, 4000000,5000000};
i=1;
myfreq = band[i];

printf shows the correct value.

This makes no sense to me. Please tell me what causes the first method to fail.

Thanks Question
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 1:15 pm     Reply with quote

Post a small but complete test program that shows the problem,
so that we can see what PIC you're using, and we can test the program.

Also post your compiler version.
ringram2077



Joined: 07 Sep 2008
Posts: 2
Location: Alabama

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 3:24 pm     Reply with quote

My compiler is version PCWH 4.081

I cut my code down to the bare minimum to make a test case for the problem. Well with the cut down version the data table worked fine, no problem. Hmmmm. So I started adding things back into the code. There is an include file with a number of functions that I use and they all work correctly. However, I found that calling a function in the include file caused the odd behavior with the data table to return. So as a test I moved one of the functions from the include file into the main code and commented out the include file. Calling the function now did not cause the odd behavior with the data table. This looks like some kind of compiler issue . I know a work around so I guess I will just not bother folks with this. I have had a other strange issues with the compiler before so this just seems to be another.

Thanks
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