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 support@ccsinfo.com

i2c failure above 32k address

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







i2c failure above 32k address
PostPosted: Thu Jan 09, 2003 2:32 am     Reply with quote

I'm using an 18F452 with a 64k of flash memory accessed by the i2c bus. I can access addresses below 32k, but not above. When I attempt to access an address above 32k, i an access of the address - 32k.

compiler version is: 3.127

Here's the "open" routine to setup for the read.

#define WORD unsigned long // Data type definitions
#define EEROM_ADDR 0xa0 // i2c addr for external EEROM


void
open_file(WORD start, WORD offset, BYTE writeAccess)
{
offset += start;
i2c_start();
i2c_write(EEROM_ADDR); // Write start pointer to eerom
//set ms byte of address
i2c_write(offset >> 8);
//set ls bits of address
// by trunction during argument pass
i2c_write(offset);

// if not write, must be read, so restart as read
if (!writeAccess)
{
i2c_stop();
i2c_start();
i2c_write(EEROM_ADDR | 1); // set for reads
}
}

The code invokes the

open_file(32768, 0, READ_ACCESS);
data = i2c_read();

The address read will be at 0.

thanks

lance
(slz)
___________________________
This message was ported from CCS's old forum
Original Post ID: 10553
Tomi
Guest







Re: i2c failure above 32k address
PostPosted: Thu Jan 09, 2003 4:05 am     Reply with quote

<font face="Courier New" size=-1>What is the type of your 64k memory?
If it is a 24LC515 then keep in mind that it is divided onto two 32k parts. The first part is accessed at address 0xA0 and the 2nd part's I2C address is 0xA8.

:=I'm using an 18F452 with a 64k of flash memory accessed by the i2c bus. I can access addresses below 32k, but not above. When I attempt to access an address above 32k, i an access of the address - 32k.
:=
:=compiler version is: 3.127
:=
:=Here's the "open" routine to setup for the read.
:=
:=#define WORD unsigned long // Data type definitions
:=#define EEROM_ADDR 0xa0 // i2c addr for external EEROM
:=
:=
:=void
:=open_file(WORD start, WORD offset, BYTE writeAccess)
:={
:= offset += start;
:= i2c_start();
:= i2c_write(EEROM_ADDR); // Write start pointer to eerom
:= //set ms byte of address
:= i2c_write(offset >> 8);
:= //set ls bits of address
:= // by trunction during argument pass
:= i2c_write(offset);
:=
:= // if not write, must be read, so restart as read
:= if (!writeAccess)
:= {
:= i2c_stop();
:= i2c_start();
:= i2c_write(EEROM_ADDR | 1); // set for reads
:= }
:=}
:=
:=The code invokes the
:=
:=open_file(32768, 0, READ_ACCESS);
:=data = i2c_read();
:=
:=The address read will be at 0.
:=
:=thanks
:=
:=lance
:=(slz)</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10554
Lance Zaklan
Guest







Re: i2c failure above 32k address
PostPosted: Thu Jan 09, 2003 2:04 pm     Reply with quote

yes. that's it. thank you

lance

:=<font face="Courier New" size=-1>What is the type of your 64k memory?
:=If it is a 24LC515 then keep in mind that it is divided onto two 32k parts. The first part is accessed at address 0xA0 and the 2nd part's I2C address is 0xA8.
:=
:=:=I'm using an 18F452 with a 64k of flash memory accessed by the i2c bus. I can access addresses below 32k, but not above. When I attempt to access an address above 32k, i an access of the address - 32k.
:=:=
:=:=compiler version is: 3.127
:=:=
:=:=Here's the "open" routine to setup for the read.
:=:=
:=:=#define WORD unsigned long // Data type definitions
:=:=#define EEROM_ADDR 0xa0 // i2c addr for external EEROM
:=:=
:=:=
:=:=void
:=:=open_file(WORD start, WORD offset, BYTE writeAccess)
:=:={
:=:= offset += start;
:=:= i2c_start();
:=:= i2c_write(EEROM_ADDR); // Write start pointer to eerom
:=:= //set ms byte of address
:=:= i2c_write(offset >> 8);
:=:= //set ls bits of address
:=:= // by trunction during argument pass
:=:= i2c_write(offset);
:=:=
:=:= // if not write, must be read, so restart as read
:=:= if (!writeAccess)
:=:= {
:=:= i2c_stop();
:=:= i2c_start();
:=:= i2c_write(EEROM_ADDR | 1); // set for reads
:=:= }
:=:=}
:=:=
:=:=The code invokes the
:=:=
:=:=open_file(32768, 0, READ_ACCESS);
:=:=data = i2c_read();
:=:=
:=:=The address read will be at 0.
:=:=
:=:=thanks
:=:=
:=:=lance
:=:=(slz)</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10572
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