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

CCS Structures

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







CCS Structures
PostPosted: Wed Jul 28, 2004 5:44 am     Reply with quote

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
Ttelmah
Guest







Re: CCS Structures
PostPosted: Wed Jul 28, 2004 7:44 am     Reply with quote

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
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 28, 2004 7:56 am     Reply with quote

I would think it's a problem with write_program_memory(), and not a problem with pointers.
Guest








PostPosted: Wed Jul 28, 2004 8:13 am     Reply with quote

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
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 28, 2004 9:26 am     Reply with quote

Maybe.

Don't forget that write_program_memory() will erase the block depending on what address you give it.
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 28, 2004 12:05 pm     Reply with quote

Trampas,

please e-mail me.
Guest








PostPosted: Wed Jul 28, 2004 2:12 pm     Reply with quote

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
UKH



Joined: 13 Jul 2004
Posts: 3
Location: Germany

View user's profile Send private message

write_program_memory
PostPosted: Fri Jul 30, 2004 2:03 am     Reply with quote

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. Sad

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"
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