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

I am lost the embedding data EEPROM

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



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

I am lost the embedding data EEPROM
PostPosted: Wed Nov 11, 2009 2:30 pm     Reply with quote

Hi, I am use the #ROM preprocessor directive to embedding data EEPROM during programming the pic18f452, but when I want to to read this data, it simply altered or lost, there is something I am forgetting?

Code:
#rom int8 0xf00001 = {"21"}
#rom int8 0xf0002D = {"OFF"}         
#rom int8 0xf00039 = {"00:10:00"}


But when I do the simulation using the proteus everything is OK
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 11, 2009 2:51 pm     Reply with quote

Post a very short, compilable test program that shows the problem.

Post your compiler version.
Guest








PostPosted: Wed Nov 11, 2009 3:52 pm     Reply with quote

Hi PCM programmer, here is my code:

Code:
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv=PIN_C7)// RS232 Estándar

int i;

#rom int8 0xf00001 = {"21"}
#rom int8 0xf0002D = {"OFF"}         
#rom int8 0xf00039 = {"00:10:00"}

void main(){
char buffer [8];

   for (i = 0 ; i<8 ; i++)
      buffer[i] = read_eeprom(57+i);
   printf("%s ",buffer);

while (true);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 11, 2009 3:58 pm     Reply with quote

What's a string ? Look at a FAQ:
http://www.macdonald.egate.net/CompSci/hstrings.html
He says:
Quote:

In C, a string is stored as a null-terminated char array.
This means that after the last truly usable char there is
a null, hex 00, which is represented in C by '\0'.


Look at your code:
Quote:

#rom int8 0xf00039 = {"00:10:00"}

char buffer [8];

for (i = 0 ; i<8 ; i++)
buffer[i] = read_eeprom(57+i);
printf("%s ",buffer);

Your string buffer doesn't have room for the 0x00 at the end,
and you don't put it there. It's not a string.
pilar



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

PostPosted: Fri Nov 13, 2009 8:04 am     Reply with quote

Embarassed You're right
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