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

12F675 eeprom write problems

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



Joined: 02 Dec 2003
Posts: 6

View user's profile Send private message

12F675 eeprom write problems
PostPosted: Mon Feb 02, 2004 4:19 am     Reply with quote

Hi,
I'm trying to write a measured calibration value to the 12f675 eeprom during program run.

(Working with MPLab 6.40 & PCM3.184)

I've tried write_eeprom(), the eeprom data is unchanged.
Tracing up to it using ICD2 debug shows the correct address & data values being used & the 'write' code looks fine when compared to the data sheet, but no actual write.

I've also tried Mark Hahn's code from another post on here
http://www.ccsinfo.com/forum/viewtopic.php?t=3694&highlight=12f675+eeprom

but with the present version of the compiler it does not produce workable code (the 0x55 / 0xAA section has other instructions in it, regardless of #opt level).

The write routine is only called once 'on demand', triggered by a switch input & timer sequence.

(I have tried the code stand-alone in a normal 12f675 in case the ICD was causing timing problems, but it still does'nt write).

Any ideas appreciated!
_________________
Robert Jenkins
Worksop, UK.
Ttelmah
Guest







Re: 12F675 eeprom write problems
PostPosted: Mon Feb 02, 2004 9:06 am     Reply with quote

rajenkins wrote:
Hi,
I'm trying to write a measured calibration value to the 12f675 eeprom during program run.

(Working with MPLab 6.40 & PCM3.184)

I've tried write_eeprom(), the eeprom data is unchanged.
Tracing up to it using ICD2 debug shows the correct address & data values being used & the 'write' code looks fine when compared to the data sheet, but no actual write.

I've also tried Mark Hahn's code from another post on here
http://www.ccsinfo.com/forum/viewtopic.php?t=3694&highlight=12f675+eeprom

but with the present version of the compiler it does not produce workable code (the 0x55 / 0xAA section has other instructions in it, regardless of #opt level).

The write routine is only called once 'on demand', triggered by a switch input & timer sequence.

(I have tried the code stand-alone in a normal 12f675 in case the ICD was causing timing problems, but it still does'nt write).

Any ideas appreciated!

I am using the EEPROM read/write on these chips, with no problems. Could you post an example of the code, so we have a chance to see what is (or is not) happening!.
I am using:
Code:


//Routine to get a block of data from the EEPROM
void get_eeprom_block(int8 *locn,int8 nbytes,int8 address) {
   int8 count;
   for (count=0;count<nbytes;count++) {
      *(locn++)=READ_EEPROM(address++);
   }
}

//Routine to write a block of data to the EEPROM
void put_eeprom_block(int8 *locn,int8 nbytes,int8 address) {
   int8 count;
   for (count=0;count<nbytes;count++) {
      WRITE_EEPROM(address++,*(locn++));
   }
}

Which I call with the address of the variables to read/write, the number of bytes to transfer, and the address in the EEPROM to be used.
One comment, perhaps try with an older compiler?. Just occasionally, 'oddities' appear on latter releases. Maybe this is one...
The other obvious thing, is that if the write protect bit had been set for the data_eeprom, it'd behave like this. Make sure you have NOCPD selected in your fuses, and do a full erase of the chip before programming.

Best Wishes
Mark



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

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

PostPosted: Mon Feb 02, 2004 3:32 pm     Reply with quote

When working with the ICD2 you must read the eeprom from MPLAB to see the data. It does NOT update when you stop or single step. You can go to the program tab on the ICD2 settings and choose only to read the eeprom to speed up debugging. However, remember to reselect the program space when you need to download again.
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