View previous topic :: View next topic |
Author |
Message |
ritchie
Joined: 13 Sep 2003 Posts: 87
|
program eeprom help |
Posted: Fri Jan 23, 2004 12:11 am |
|
|
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
|
|
Posted: Fri Jan 23, 2004 2:38 am |
|
|
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
|
|
Posted: Fri Jan 23, 2004 7:36 am |
|
|
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
|
|
Posted: Mon Jan 26, 2004 3:46 am |
|
|
Hello Mark,
I'm not sure, but is it possible that you're wrong? Please don't hit me!!!
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
|
|
Posted: Mon Jan 26, 2004 7:29 am |
|
|
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
|
|
Posted: Mon Jan 26, 2004 10:05 am |
|
|
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 |
|
|
|