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

interfacing 12f675 with 24fc515
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

interfacing 12f675 with 24fc515
PostPosted: Thu Jul 08, 2004 11:11 am     Reply with quote

I need to write/read data to/from 24fc515 eprom using 12f675, anyone interfacing graph and sample programming? thanks in advance for any effort!
valemike
Guest







Just use the internal eeprom
PostPosted: Thu Jul 08, 2004 11:27 am     Reply with quote

I have no graphs to show you, but I suggest you just use the internal eeprom of the 12F675.

Saves you hardware, and the eeprom_read() and eeprom_write() functions are conveniently there at your disposal.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

memory is not big enough
PostPosted: Thu Jul 08, 2004 11:45 am     Reply with quote

Thank you valemike:
It is the best way if I need a small storage(memory) space, my project will need a much bigger storage, this is why I am looking for 24fc515.

welcome more response and thank you again valemike
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

a0, a1 pin
PostPosted: Thu Jul 08, 2004 1:28 pm     Reply with quote

I figured that a2->Vcc Vcc->5V Vss->ground, WP->Vcc, SDA-one of the port pin, SCL->another pin, How about the a0, and a1 and if I have 2-4 14fc515 how to connect them?
valemike
Guest







PostPosted: Thu Jul 08, 2004 1:50 pm     Reply with quote

Looks like you can have up to 4 different eeproms.

Just make sure you uniquely pull up/down each pin with unique logic levels:

a1/a0
00
01
10
11

a2 needs to be pulled to vcc.
~~~~~~~~~
And all of their sda and scl pins also go to the same PIC's sda/scl pins.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 08, 2004 2:00 pm     Reply with quote

Thank you:

According to your suggestion, It should be like this
for first 24fc515
a1-->vss, a0-->vss
for second 24fc515
a1-->vss,a0-->vcc
for third 24fc515
a1-->vcc, a0-->vss
for fourth 24fc515
a1-->vcc, a0-->vcc

right?

and how about the drivers, do you have any drivers for 24fc515?

Really appreciate to help me make clear the connection.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Jul 08, 2004 2:38 pm     Reply with quote

Here is a bit of code that I use with four of those eeproms. You will need to keep track where you want to save the data, in each eeprom. Make sure you read over the data sheet really well. That will help you understand just how things should work.

Code:

void store_data(int8 add)
{
unsigned int8 pp;

// this secion writes data TO the eeprom

   switch(ss)// 'ss' tracks which eeprom will be written to and pulls down the
   {   // WP line of that eeprom. they are tied to D0-D3, also a global variable
      CASE 0:
         output_low(PIN_D0);
         output_high(PIN_D1);
         output_high(PIN_D2);
         output_high(PIN_D3);
         break;
      CASE 1:
         output_high(PIN_D0);
         output_low(PIN_D1);
         output_high(PIN_D2);
         output_high(PIN_D3);
         break;
      CASE 2:
         output_high(PIN_D0);
         output_high(PIN_D1);
         output_low(PIN_D2);
         output_high(PIN_D3);
         break;
      CASE 3:
         output_high(PIN_D0);
         output_high(PIN_D1);
         output_high(PIN_D2);
         output_low(PIN_D3);
         break;
      default:
         break;
   }// end of switch
   for(pp = 0; pp < 2; pp++)// just a quick pause statement
   {
      ;
   }
      // 'memory' is a global variable that tracks where we want to write to, in the eeprom
   if(memory > 0x7FFF)// if the memory address is above 0x7FFF then set the 'block select' bit
   {                        // in order to access it.
      bit_set(add, 3);
   }

   i2c_start();
   i2c_write(add);                   // address for eeprom - write mode
   i2c_write((memory >> 8) & 0xFF); // select the MSB of the memory location
   i2c_write(memory & 0xFF);        // select the LSB of the memory location
   i2c_write((variable1);  // save the value to be stored
   i2c_write(variable2);// save sequential data if you want in blocks from 0h - 7FFFh or
   i2c_write((variable3);// 8000h - FFFFh
   i2c_write(variable4);
   i2c_stop();

   output_high(PIN_D0);
   output_high(PIN_D1);
   output_high(PIN_D2);
   output_high(PIN_D3);

}// end of store_data()


Hope this helps.

Ronald
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Thu Jul 08, 2004 2:58 pm     Reply with quote

Hi rnielsen:

I really appreciate it. It is a great help, I will try it immediately after understanding it a little bit.
Guest








PostPosted: Fri Jul 09, 2004 9:30 am     Reply with quote

Hi rnielsen:
what does i2c_write(add); means? and how to decide the address "add"? usually, I saw in 24lc256.c it is 0xa0 for 0x0000-0x7fff, and 0xa1 for 0x8000-0xffff, why?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 9:47 am     Reply with quote

If you will look at the top of the routine, I am passing a variable to the function. It is declared as an 8bit variable called 'add'. This is the address that will be used in accessing the correct eeprom. You can have up to four eeproms that you use. The data sheet notes that the control byte, to address the eeprom, is as follows:

MSB___________LSB
1 0 1 0 B0 A1 A0 R/W

The four MSB bits are hard coded. B0 decides if you access the memory area 0 - 7FFFh or 8000 - FFFF. If B0 is a 'zero' then 0 - 7FFF will be accessed, if it is a 'one' then 8000 - FFFF will be accessed. A1 and A0 correspond to the pins on the actual part. These two decide the address of each eeprom. R/W is the standard I2C bit that decides if you will be Reading from or Writing to the eeprom. So, if you have an eeprom that has both A1 and A0 tied to GND then the control code, assuming you will be accessing the Lower portion of the memory location, will be:

10100000 or 0xA0

If you want to access the Upper portion of the memory location then the address will be:

10101000 or 0xA8

Read up on the data sheet a bit more and see if this makes sense.

Ronald
Guest








PostPosted: Fri Jul 09, 2004 10:52 am     Reply with quote

Thank you and thank you:
According to your response and my understanding it is
1, i2C_start() start the communication between i2c and pic
2, following the start command, i2c_write(cmd) tell which part of the eeprom to read and write,
3, following this i2c_write(cmd) is a i2c_write(address) tell msb memory location, and another i2c_write(address) tell the LSB memory location,
4, sending data by i2c_write(data);

am I right, how about the meaning of
i2c_stop();
i2c_start();
status=i2c_write(0xa0);
while(status)
{
i2c_start();
status=i2c_write(0xa0);
}

what does the status mean here, to check if the writing is success?

thank you again
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 1:59 pm     Reply with quote

When I use i2c_write(0xa0) after i2c_start;
the program hold there, did nor go ahead, what happened?
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 2:05 pm     Reply with quote

Allright, I found out, it is because I did not pull up the sda pin.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 2:46 pm     Reply with quote

You might want to put pull-ups on both the SDA and SCL lines.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Fri Jul 09, 2004 3:06 pm     Reply with quote

What kinds of registerto use, some register work, some not, and I feel weired that I did not pull up sda, I pull up sdc, and it worked, when I just pull up sda, it did not work, which means only when sdc is pull up, the program continue to run.

when I tried to read the data from the eeprom, it updated very slowly, and it is all zero, the data I collected might not save into eeprom?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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