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

EE_PROM addressing above addr 255

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







EE_PROM addressing above addr 255
PostPosted: Thu May 22, 2003 6:54 am     Reply with quote

The PIC18F6720 has 1K of data EEPROM; How can I address it if the CCS functions for reading and writing take only an 8-bit address?

Phil G
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514669
Tomi
Guest







Re: EE_PROM addressing above addr 255
PostPosted: Thu May 22, 2003 7:06 am     Reply with quote

The trivial solution is:
void MyWrite_eeprom(unsigned long addr,char data)
{
#byte addrL = addr
#byte addrH = addr+1

*0x0FAA = addrH; // load upper addr byte
Write_eeprom(addrL,data);
}

char MyRead_eeprom(unsigned long addr)
{
#byte addrL = addr
#byte addrH = addr+1

*0x0FAA = addrH; // load upper addr byte
return read_eeprom(addrL);
}

:=The PIC18F6720 has 1K of data EEPROM; How can I address it if the CCS functions for reading and writing take only an 8-bit address?
:=
:=Phil G
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514670
Woody
Guest







Re: EE_PROM addressing above addr 255
PostPosted: Fri May 23, 2003 1:41 am     Reply with quote

Although the CCS documentation and help file state that the parameter to the EEPROM library functions is an int, a test with PCWH version 3.158 shows that it is correctly using a long parameter for the 18F6720.

Apparently the documentation has not caught up with the compiler capabilities.


#include <18F6720.h>

void main (void)
{
long a = 700;

write_eeprom (a, 55 );

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514691
rret
Guest







Re: EE_PROM addressing above addr 255
PostPosted: Tue Jul 22, 2003 1:14 pm     Reply with quote

:=The trivial solution is:
:=void MyWrite_eeprom(unsigned long addr,char data)
:={
:=#byte addrL = addr
:=#byte addrH = addr+1
:=
:=*0x0FAA = addrH; // load upper addr byte
:=Write_eeprom(addrL,data);
:=}
:=
:=char MyRead_eeprom(unsigned long addr)
:={
:=#byte addrL = addr
:=#byte addrH = addr+1
:=
:=*0x0FAA = addrH; // load upper addr byte
:=return read_eeprom(addrL);
:=}
:=
:=:=The PIC18F6720 has 1K of data EEPROM; How can I address it if the CCS functions for reading and writing take only an 8-bit address?
:=:=
:=:=Phil G

I understand where you get the 0x0FAA, but what do you pass in for the "addr" parameter when you call MyWrite_eeprom()?
(Say you wish to write a byte to the first eeprom "cell".)
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516254
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