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

CCS internal_eeprom.c routines

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



Joined: 25 Sep 2006
Posts: 38
Location: Adelaide, Australia

View user's profile Send private message

CCS internal_eeprom.c routines
PostPosted: Sat Apr 28, 2007 10:43 pm     Reply with quote

I'm just looking at the CCS internal_eeprom.c file and there's something I don't understand. Whenever I'm writing several bytes of data to the internal EEprom I set a flag then wait for the INT_EEPROM interrupt before writting the next byte. It appears to take several milli secs between writes.

On the other hand, the CCS routines in the internal_eeprom.c file don't even have a time delay between writes and they appear to just blasting data at the EEprom in a FOR loop.

Can someone explain to me how the CCS routines work when I know it take longer to write a byte
Ttelmah
Guest







PostPosted: Sun Apr 29, 2007 2:45 am     Reply with quote

Their own 'write_eeprom' code, tests for the write to complete internally.
If you look at the code generated, for the command:

WRITE_EEPROM(addr+count,ptr[count]);

Ignore all the stuff 'loading' the data bytes, you get to:

1750: MOVWF FA7
1752: BSF FA6.1
1754: BTFSC FA6.1
1756: BRA 1754
1758: BCF FA6.2
175A: MOVF 00,W
175C: IORWF FF2,F

Notice the third, and fourth lines, where it sets the 'write' bit in EECON1, and then waits for it to clear. If you read the data sheet about this bit, it says:
" Initiates a data EEPROM erase/write cycle or a program memory erase cycle or write cycle. (The operation is self-timed and the bit is cleared by hardware once write is complete. The WR bit can only be set (not cleared) in software.) "
So, they are waiting for this bit to clear which implies the operation has completed.

Best Wishes
MarcosAmbrose



Joined: 25 Sep 2006
Posts: 38
Location: Adelaide, Australia

View user's profile Send private message

PostPosted: Mon Apr 30, 2007 10:39 pm     Reply with quote

Ttelmah wrote:
Their own 'write_eeprom' code, tests for the write to complete internally.


Hi Ttelmah, Thanks for that! I continue to learn something new everyday. -Cheers
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