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

program eeprom help

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



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

program eeprom help
PostPosted: Fri Jan 23, 2004 12:11 am     Reply with quote

Mabuhay!

My code below does not provide good result . The output is 0034... the higher byte disappear and replace with zero.

Any help?

Code:

main()
{
   unsigned int16 result;
   
   write_program_eeprom(0x7ff0,0x1234);
   delay_ms(5000);
   result = read_program_eeprom(0x7ff0);
   printf("REesult = %4x",result);
}



Thanx
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Fri Jan 23, 2004 2:38 am     Reply with quote

Hello ritchie,
I think the problem is the use of the 'fprintf' command

Please try:

Code:

main()
{
   unsigned int16 result;
   
   write_program_eeprom(0x7ff0,0x1234);
   delay_ms(5000);
   result = read_program_eeprom(0x7ff0);
   //printf("REesult = %4x",result);
   printf("REesult = %4lx",result);      // use an l between 4 and x
}


Hope to help you
73 Sven
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Fri Jan 23, 2004 7:36 am     Reply with quote

Take a look at the manual. read_program_eeprom() only returns a 8bit number which is why you are missing the high byte. You will have to read 2 bytes and then make a 16bit number.
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Mon Jan 26, 2004 3:46 am     Reply with quote

Hello Mark,
I'm not sure, but is it possible that you're wrong? Please don't hit me!!! Laughing

read_program_eeprom() returns already 16bit.
I think you mean read_eeprom() which returns only 8bit integer.

I hope I don't talk rot here
73 Sven
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Jan 26, 2004 7:29 am     Reply with quote

SMACK.... Just kidding.

This guy is using a 18F part (I know because I have helped him a bunch) which uses the PCH compiler. If you check the manual, it states that read_program_eeprom() returns an 8 bit number for PCH devices.
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Mon Jan 26, 2004 10:05 am     Reply with quote

Hello Mark,
Now I'm totally confused.
Yes, in my printed version of the ccs manual (February 2002) it is like you say.
In the current pdf version (July 2003) you can find this here:

Quote:

READ_PROGRAM_EEPROM()
...
some stuff deleted
...
Returns: 16 bits
Function: Reads data from the program memory.
Availability: Only devices that allow reads from program memory.
Requires Nothing
...
some stuff deleted
...


So, what is correct?

73 Sven
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