View previous topic :: View next topic |
Author |
Message |
Phil G Guest
|
EE_PROM addressing above addr 255 |
Posted: Thu May 22, 2003 6:54 am |
|
|
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 |
Posted: Thu May 22, 2003 7:06 am |
|
|
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 |
Posted: Fri May 23, 2003 1:41 am |
|
|
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 |
Posted: Tue Jul 22, 2003 1:14 pm |
|
|
:=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 |
|
|
|