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

18F452 Data EEPROM Writes Don't Work (write_eeprom(addr,data

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







18F452 Data EEPROM Writes Don't Work (write_eeprom(addr,data
PostPosted: Sat Nov 09, 2002 4:23 pm     Reply with quote

During my conversion efforts to upgrade to the 18F452 from the 16F877 I ran into a write_eeprom(), read_eeprom() problem. THe program previously worked on the 16F877 so it is a port of good code. I'm using PCWH v3.123 and the PICALLW 0.13d version of the programmer software for my PICALL programmer. None of my writes to the data EEPROM appear to work, at least they don't get read back. I looked into the Configuration bits, CONFIGURATION Register 6 High, WRTD (bit 7) using the config bit view option on PICALLW and I see the bit (WRTD) off when I do nothing special with the fuses (ie default). The WRTD bit, according to the datasheet (pg 200) shows WRTD needs to be on. So, I looked at the valid fuses CCS has in the latest GUI and find that there are options WRTD and NOWRTD. Well, these behave backwards from what they are supposed to set. #FUSE ....,WRTD sets the bit to 0 instead of 1 and the NOWRTD reverses that, sets to 1 instead of 0. In both cases, the write_eeprom() doesn't work. Program goes through the motions with no objections, but the reads come back as the erased state of 0xFF.

Any ideas? Workarounds? Is this a known problem?
___________________________
This message was ported from CCS's old forum
Original Post ID: 8714
Steve Stolen
Guest







Re: 18F452 Data EEPROM Writes Don't Work (write_eeprom(addr,
PostPosted: Sat Nov 09, 2002 7:11 pm     Reply with quote

:=During my conversion efforts to upgrade to the 18F452 from the 16F877 I ran into a write_eeprom(), read_eeprom() problem. THe program previously worked on the 16F877 so it is a port of good code. I'm using PCWH v3.123 and the PICALLW 0.13d version of the programmer software for my PICALL programmer. None of my writes to the data EEPROM appear to work, at least they don't get read back. I looked into the Configuration bits, CONFIGURATION Register 6 High, WRTD (bit 7) using the config bit view option on PICALLW and I see the bit (WRTD) off when I do nothing special with the fuses (ie default). The WRTD bit, according to the datasheet (pg 200) shows WRTD needs to be on. So, I looked at the valid fuses CCS has in the latest GUI and find that there are options WRTD and NOWRTD. Well, these behave backwards from what they are supposed to set. #FUSE ....,WRTD sets the bit to 0 instead of 1 and the NOWRTD reverses that, sets to 1 instead of 0. In both cases, the write_eeprom() doesn't work. Program goes through the motions with no objections, but the reads come back as the erased state of 0xFF.
:=
:=Any ideas? Workarounds? Is this a known problem?

I thought I would back up to the last known fairly stable version (I guessed at 3.110 because CCS has that version as the alternate download). I recompiled, checked the fuses with PICALLW, found a lot of fuses were set at FFFF in the config words, changed Conf Word 6Hi to 0x80 to turn on the WRTD flag, popped the PIC into the target hardware, and the write/read_eeprom() functions now appear to work. So, now I gotta get together the audit trail and send in a bug report. The newer fixes/features I also need, but can cope with this for now.
___________________________
This message was ported from CCS's old forum
Original Post ID: 8716
SL1978
Guest







Re: 18F452 Data EEPROM Writes Don't Work (write_eeprom(addr,
PostPosted: Mon Nov 11, 2002 2:45 am     Reply with quote

:=During my conversion efforts to upgrade to the 18F452 from the 16F877 I ran into a write_eeprom(), read_eeprom() problem. THe program previously worked on the 16F877 so it is a port of good code. I'm using PCWH v3.123 and the PICALLW 0.13d version of the programmer software for my PICALL programmer. None of my writes to the data EEPROM appear to work, at least they don't get read back. I looked into the Configuration bits, CONFIGURATION Register 6 High, WRTD (bit 7) using the config bit view option on PICALLW and I see the bit (WRTD) off when I do nothing special with the fuses (ie default). The WRTD bit, according to the datasheet (pg 200) shows WRTD needs to be on. So, I looked at the valid fuses CCS has in the latest GUI and find that there are options WRTD and NOWRTD. Well, these behave backwards from what they are supposed to set. #FUSE ....,WRTD sets the bit to 0 instead of 1 and the NOWRTD reverses that, sets to 1 instead of 0. In both cases, the write_eeprom() doesn't work. Program goes through the motions with no objections, but the reads come back as the erased state of 0xFF.
:=
:=Any ideas? Workarounds? Is this a known problem?

There are some bug there but u can my routine, it work

#define EEADR 0xFA9
#define EEDATA 0xFA8
#define EECON1 0xFA6
#define RD 0
#define WR 1
#define WREN 2
#define WRERR 3
#define FREE 4
#define CFGS 6
#define EEPGD 7

#define EECON2 0xFA7
#define PIR2 0xFA1
#define EEIF 4

void write_int_eeprom(int address, int data)
{
bit_clear(*EECON1, CFGS); //access prog or data memory
bit_clear(*PIR2, EEIF); // Make sure that the int flag is cleared
(int)*EEADR = address; // Load our address
(int)*EEDATA = data; // Load our data
bit_clear(*EECON1, EEPGD); // Point to data memory
bit_set(*EECON1, WREN); // Enable writes

// Microchip recommends disabling ints here
disable_interrupts(GLOBAL); //note must modify to wait for int complete
(int)*EECON2 = 0x55; // Write 0x55
(int)*EECON2 = 0xAA; // Write 0xAA
bit_set(*EECON1, WR); // Set WR to begin write

// Ok to turn back on ints
enable_interrupts(GLOBAL);

// Wait for the write to complete
while (!bit_test(*PIR2, EEIF));
bit_clear(*EECON1, WREN); // disable writes
bit_clear(*PIR2, EEIF);
}

/*-------------------- Read Int EEPROM subroutine ---------------------------
-----------------------------------------------------------------------------
*/
int read_int_eeprom(int address)
{
bit_clear(*EECON1, CFGS); //access prog or data memory
(int)*EEADR = address; // Load our address
bit_clear(*EECON1, EEPGD); // Point to data memory
bit_set(*EECON1, RD); // EEPROM Read

return(*EEDATA); // Return with our value
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8744
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