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

Write_eeprom()

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



Joined: 10 Dec 2003
Posts: 70
Location: West Sussex, UK

View user's profile Send private message

Write_eeprom()
PostPosted: Thu Sep 18, 2008 10:22 am     Reply with quote

I am using PCWH 3.249 and PCWHD 4.073.

PIC 18F252

At background in my code I call write_eeprom(), but as it masks interrupts for the entire time it takes to write data to the internal eeprom, I have difficulty in servicing other interrupts adequately.

From the compiler I get (same results from both versions of compiler)
Code:

CCS compiler code masking interrupts for duration of EE write cycle

....................    write_eeprom(offset,data);
*
0C14:  MOVFF  136,FA9
0C18:  MOVFF  137,FA8
0C1C:  BCF    FA6.6
0C1E:  BCF    FA6.7
0C20:  BSF    FA6.2
0C22:  MOVFF  FF2,00
0C26:  BCF    FF2.6
0C28:  BCF    FF2.7
0C2A:  MOVLB  F
0C2C:  MOVLW  55
0C2E:  MOVWF  FA7
0C30:  MOVLW  AA
0C32:  MOVWF  FA7
0C34:  BSF    FA6.1
<<  >>                              why is the re-enable of interrupts not here ??
0C36:  BTFSC  FA6.1         ** this line spins until write complete
0C38:  BRA    0C36           **typ 4ms according to datasheet
0C3A:  BCF    FA6.2
0C3C:  MOVF   00,W           ** this is the bit that re-enables irq
0C3E:  IORWF  FF2,F
....................
.................... }
0C40:  MOVLB  0
0C42:  RETLW  00
....................


My analysis of the 18F252 data sheet suggests interrupts only need to be disabled whilst we "unlock" the device and start the actual write cycle.

Is there a known switch in the CCS compiler that re-enables irq at the point I have marked above ??

I have tried the #device WRITE_EEPROM=ASYNC, but that seems to result in unreliable writes to the EEPROM. It places the check for write competion on entry to the code, which means I can exit and attempt a read BEFORE the write has actually completed ....

any ideas

regards
_________________
Peter Willis
Development Director
Howard Eaton Lighting Ltd UK
Guest








PostPosted: Thu Sep 18, 2008 11:36 am     Reply with quote

I don't know if write_program_eeprom and write_program_memory are faster than write_eeprom. You could check. And then you could write your data somewhere at the end of the program memory space. I think you can also write blocks of 64 bytes with write_program_memory ... that surely should be faster.
Just a guess ... good luck
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