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

eeprom writing in 18f series...

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







eeprom writing in 18f series...
PostPosted: Tue Jul 22, 2003 2:18 pm     Reply with quote

I am trying to use CCS's write_eeprom() function to load data into 18F6720 eeprom (sits at 0faa:0fa9 ???).
how do i do this?
someone (tomi) had this function:

void MyWrite_eeprom(unsigned long addr, char data)
{
#byte addrL = addr
#byte addrH = addr+1
*0x0FAA = addrH;
Write_eeprom(addrL, data);
}

I understand the 0x0FAA, but what gets passed in as "addr" if I wish to write one byte to the first "cell" in the eeprom address space???
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516261
R J Hamlett
Guest







Re: eeprom writing in 18f series...
PostPosted: Tue Jul 22, 2003 3:18 pm     Reply with quote

:=I am trying to use CCS's write_eeprom() function to load data into 18F6720 eeprom (sits at 0faa:0fa9 ???).
:=how do i do this?
:=someone (tomi) had this function:
:=
:=void MyWrite_eeprom(unsigned long addr, char data)
:={
:=#byte addrL = addr
:=#byte addrH = addr+1
:=*0x0FAA = addrH;
:=Write_eeprom(addrL, data);
:=}
:=
:=I understand the 0x0FAA, but what gets passed in as "addr" if I wish to write one byte to the first "cell" in the eeprom address space???

The latest compilers do now do this without you having to 'fiddle'. However to do what you want, on slightly older versions, code as:
#byte EEADRH=0xFAA
union baccess {
unsigned long word;
int8[2] b;
}

void MyWrite_eeprom(struct baccess address, char data)
{
EEADRH=address.b[1];
Write_eeprom(address.b[0], data);
}

Your address, is a unsigned long, with '0' corresponding to the first memory cell.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516266
rret
Guest







Re: eeprom writing in 18f series...
PostPosted: Wed Jul 23, 2003 12:36 pm     Reply with quote

:=:=I am trying to use CCS's write_eeprom() function to load data into 18F6720 eeprom (sits at 0faa:0fa9 ???).
:=:=how do i do this?
:=:=someone (tomi) had this function:
:=:=
:=:=void MyWrite_eeprom(unsigned long addr, char data)
:=:={
:=:=#byte addrL = addr
:=:=#byte addrH = addr+1
:=:=*0x0FAA = addrH;
:=:=Write_eeprom(addrL, data);
:=:=}
:=:=
:=:=I understand the 0x0FAA, but what gets passed in as "addr" if I wish to write one byte to the first "cell" in the eeprom address space???
:=
:=The latest compilers do now do this without you having to 'fiddle'. However to do what you want, on slightly older versions, code as:
:=#byte EEADRH=0xFAA
:=union baccess {
:= unsigned long word;
:= int8[2] b;
:=}
:=
:=void MyWrite_eeprom(struct baccess address, char data)
:={
:=EEADRH=address.b[1];
:=Write_eeprom(address.b[0], data);
:=}
:=
:=Your address, is a unsigned long, with '0' corresponding to the first memory cell.
:=
:=Best Wishes

thanks for responding - seems no one is using my b-i-g pic!
ok, i'm using CCS ver 3.162 (pretty new) and an 18f6720 (128K).
so i can just use:

#include <18F6720.H>
write_eeprom(0,'A');
b=read_eeprom(0);

and the compiler is smart enough to store an 'A' in "cell" 0 and also to return it in b?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516292
R.J.Hamlett
Guest







Re: eeprom writing in 18f series...
PostPosted: Wed Jul 23, 2003 2:57 pm     Reply with quote

:=:=:=I am trying to use CCS's write_eeprom() function to load data into 18F6720 eeprom (sits at 0faa:0fa9 ???).
:=:=:=how do i do this?
:=:=:=someone (tomi) had this function:
:=:=:=
:=:=:=void MyWrite_eeprom(unsigned long addr, char data)
:=:=:={
:=:=:=#byte addrL = addr
:=:=:=#byte addrH = addr+1
:=:=:=*0x0FAA = addrH;
:=:=:=Write_eeprom(addrL, data);
:=:=:=}
:=:=:=
:=:=:=I understand the 0x0FAA, but what gets passed in as "addr" if I wish to write one byte to the first "cell" in the eeprom address space???
:=:=
:=:=The latest compilers do now do this without you having to 'fiddle'. However to do what you want, on slightly older versions, code as:
:=:=#byte EEADRH=0xFAA
:=:=union baccess {
:=:= unsigned long word;
:=:= int8[2] b;
:=:=}
:=:=
:=:=void MyWrite_eeprom(struct baccess address, char data)
:=:={
:=:=EEADRH=address.b[1];
:=:=Write_eeprom(address.b[0], data);
:=:=}
:=:=
:=:=Your address, is a unsigned long, with '0' corresponding to the first memory cell.
:=:=
:=:=Best Wishes
:=
:=thanks for responding - seems no one is using my b-i-g pic!
:=ok, i'm using CCS ver 3.162 (pretty new) and an 18f6720 (128K).
:=so i can just use:
:=
:=#include <18F6720.H>
:=write_eeprom(0,'A');
:=b=read_eeprom(0);
:=
:=and the compiler is smart enough to store an 'A' in "cell" 0 and also to return it in b?

Yes.
There is a 'caveat' though. You must ensure that the address being handled is a 'long'. If you code as:

write_eeprom(1,1);

It will only write to the FA9 register. However if you code as:

write_eeprom(1l,1);

It will correctly write to both registers. The same applies if you use a variable. for the address.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516300
IK1WVQ
Guest







re
PostPosted: Fri Aug 01, 2003 10:51 am     Reply with quote

:=I am trying to use CCS's write_eeprom() function to load data into 18F6720 eeprom (sits at 0faa:0fa9 ???).
:=how do i do this?
:=someone (tomi) had this function:
:=
:=void MyWrite_eeprom(unsigned long addr, char data)
:={
:=#byte addrL = addr
:=#byte addrH = addr+1
:=*0x0FAA = addrH;
:=Write_eeprom(addrL, data);
:=}
:=
:=I understand the 0x0FAA, but what gets passed in as "addr" if I wish to write one byte to the first "cell" in the eeprom address space???

hi,
i use normally the pic 18lf8720 ..
the write_eeprom(LONG addreess, int8 data)
and read_eeprom(LONG address)
work fine..

write_eeprom(0x3ff,'z')
put 'z' into the last cell of eeprom space ...

regards
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516558
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