![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Trampas Guest
|
CCS Structures |
Posted: Wed Jul 28, 2004 5:44 am |
|
|
Hello,
I created a structure simular to:
typedef struct {
CHAR data[8];
CHAR data2[4];
FLOAT value;
} myStruct;
I am using the structure to store data in the on chip Flash. That is I am trying to:
myStruct test;
sprintf(test.data,"hi");
test.value=30.0;
address=0xE000; //address in Program Flash memory
write_program_memory(address,(UBYTE *)test,sizeof(myStruct));
read_program_memory(address,(UBYTE *)test,sizeof(myStruct));
The problem is that the data gets hosed doing this. Therefore I am wondering if CCS's compiler is not treating structures as K&R C does?
Is there a list of where CCS differs from C in these hidden ways?
Thanks
Trampas |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: CCS Structures |
Posted: Wed Jul 28, 2004 7:44 am |
|
|
Trampas wrote: | Hello,
I created a structure simular to:
typedef struct {
CHAR data[8];
CHAR data2[4];
FLOAT value;
} myStruct;
I am using the structure to store data in the on chip Flash. That is I am trying to:
myStruct test;
sprintf(test.data,"hi");
test.value=30.0;
address=0xE000; //address in Program Flash memory
write_program_memory(address,(UBYTE *)test,sizeof(myStruct));
read_program_memory(address,(UBYTE *)test,sizeof(myStruct));
The problem is that the data gets hosed doing this. Therefore I am wondering if CCS's compiler is not treating structures as K&R C does?
Is there a list of where CCS differs from C in these hidden ways?
Thanks
Trampas |
As far as I can see, what you show should work. I use allmost exactly the same construct, to transfer structures to/from the internal EEPROM fine.
What chip are you using?. 0xE000, is a very 'high' address, and few chips have this much memory. Only chips 'above' the 18F4620, will have memory here to store the values.
Prove whether it is a 'structure' problem, or a read/write EEPROM problem, by transferring a small integer array instead.
I have found some problems in the past with compiler versions not liking the 'shortcut', where the name of the structure is it's address, and hence tend to use:
&test.data[0]
to get the address, rather than relying on this.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Wed Jul 28, 2004 7:56 am |
|
|
I would think it's a problem with write_program_memory(), and not a problem with pointers. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Wed Jul 28, 2004 8:13 am |
|
|
Darren,
Well the write_program_memory() is a CCS internal function call, so I guess you are saying the compiler is broken?
As far as questions about the chip, I am using a 18F8680.
Trampas |
|
![](templates/subSilver/images/spacer.gif) |
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Wed Jul 28, 2004 9:26 am |
|
|
Maybe.
Don't forget that write_program_memory() will erase the block depending on what address you give it. |
|
![](templates/subSilver/images/spacer.gif) |
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Wed Jul 28, 2004 12:05 pm |
|
|
Trampas,
please e-mail me. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Wed Jul 28, 2004 2:12 pm |
|
|
Well to keep you all updated, Darren said he could not find anything wrong with the read/write program memory functions but is going to keep looking at them...
What in the heck does that mean?
Next he wants me to send my code to him for review....
Why is it I always feel like I spend half my time debugging the compiler instead of writting code?
I do like the CCS compiler when it works. It is really good for one or two pages of code. Beyond that.....
Trampas |
|
![](templates/subSilver/images/spacer.gif) |
UKH
Joined: 13 Jul 2004 Posts: 3 Location: Germany
|
write_program_memory |
Posted: Fri Jul 30, 2004 2:03 am |
|
|
Hello together,
I think Daren is looking for an existing problem with write_program_memory(). There are some problems reported in this forum with this function, especially with latest compiler-version(s).
I found a problem as I used an update from 3.189 (here it works) to 3.204 (see my link below).
I hope that Daren found something because since 3.189 I couldn't use a never version of a compiler but some implementations of newest versions are important too.
Please take a look to:
http://www.ccsinfo.com/forum/viewtopic.php?t=19895&highlight=writeprogrammemory.
So long
UKH
"The better is the enemy of the good" |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|