View previous topic :: View next topic |
Author |
Message |
ringram2077
Joined: 07 Sep 2008 Posts: 2 Location: Alabama
|
I just don't get it ?? Data Table Question Please |
Posted: Wed Mar 17, 2010 1:06 pm |
|
|
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 :
instead of
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 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 17, 2010 1:15 pm |
|
|
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
|
|
Posted: Wed Mar 17, 2010 3:24 pm |
|
|
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 |
|
|
|