24c256

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any has C code for interfacing 24c256 with Atmega16 or ATmega128 using normal I/O pins?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey there is no one around with 24c256 code without using SCL andSDA lines!!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What you are asking for is a soft I2C implementation, Avrlib has one of those:

http://hubbard.engr.scu.edu/avr/...

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I checked it.
Will this work with:
1) With normal I/O Pins. I cant use SCL and SDApins.
2) It supports up to 64K. 24c256 is 256K EEPROM. Any suggestions. I think function parameter datatypes need to be changed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All AVRLIB gives you is bit-bang routines to wiggle "fake" SDA and SCL wires on any port pins. How you then use that is up to you. The soft-I2C implementation itself will impose no limit on the size of the EEPROM or whatever else you choose to hang off the I2C lines.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rembember 24lc256 is 256 kBITS wide, whick means 32kBYTES... so probably the lib mentioned above would work.

Carlos

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok!!!!

I wrote few lines of code with ATmega32, 1Mhz internal osc.
This is partial code:

u08 x;
i2cInit();
i2cReceive(0,1,1,(void*)x);
lcd_putc(x+48);

I have stored value 1decimal at 0 location of eeprom.
But reading 0th location returns a wrong value.

YB

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know what i2cReceive() actually does and whether
it really implements the full EEPROM protocol (which I
doubt), but anyway: converting a variable's value into a
pointer by a typecast, and then expecting the variable's
value to be changed in any way by that function for sure
won't work, ever.

Seems you need to re-read the entire chapter about
pointers and arrays in your K&R.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What Jorg means is that you should do:

u08 x; 
i2cInit(); 
i2cReceive(0,1,1,(void*) &x); 
lcd_putc(x+48);

Take a look at the ampersand &. That means you want x's address and not its value.
As mentioned by Jorg, maybe you need a good K&R refresh.

good luck
Carlos

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dl8dt8, can you share your 24c256 Serial EEPROM interfacing code using bit-banging.
YB

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> dl8dt8, can you share your 24c256 Serial EEPROM
> interfacing code using bit-banging.

No, I can't, because I don't have one.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:|

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What you are asking for is a soft I2C implementation, Avrlib has one of those:

http://hubbard.engr.scu.edu/avr/...

This is one of the function def used for bit-bang i2c:

//!Retrieve a byte sequence on the I2C bus
void i2cReceive(u08 device, u08 subAddr, u08 length, u08 *data)

Can any one tell me details of the parameters used.
I understand "device", which is as per datasheet 1010000@ , where @ can be 0 or 1 based on if you write or read.
Cant understand subaddress, etc....

any one has any idea...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrlib\docs\html contains "4,347,210 bytes" of HTML files. Are you saying that somewhere in that >4MB of documentation it doesn't document how i2creceive() is used? I find that most odd!

(in fact I just grep'd for i2cReceive in *.html there and it occurs several times)

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
00001 /*! \file i2csw.c \brief Software I2C interface using port pins. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'i2csw.c'
00005 // Title        : Software I2C interface using port pins
00006 // Author       : Pascal Stang
00007 // Created      : 11/22/2000
00008 // Revised      : 5/2/2002
00009 // Version      : 1.1
00010 // Target MCU   : Atmel AVR series
00011 // Editor Tabs  : 4
00012 //
00013 // This code is distributed under the GNU Public License
00014 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00015 //
00016 //*****************************************************************************
 .
 .
 .
00154 //! Retrieve a byte sequence on the I2C bus
00155 void i2cReceive(u08 device, u08 subAddr, u08 length, u08 *data)
00156 {
00157     int j = length;
00158     u08 *p = data;
00159 
00160     I2C_START;                  // do start transition
00161     i2cPutbyte(device);         // send DEVICE address
00162     i2cPutbyte(subAddr);        // and the subaddress
00163     HDEL;
00164     I2C_SCL_HI;                 // do a repeated START
00165     I2C_START;                  // transition
00166 
00167     i2cPutbyte(device | READ);  // resend DEVICE, with READ bit set
00168 
00169     // receive data bytes
00170     while (j--)
00171         *p++ = i2cGetbyte(j == 0);
00172 
00173     I2C_SDL_LO;                 // clear data line and
00174     I2C_STOP;                   // send STOP transition
00175 }

Quote:
Can any one tell me details of the parameters used.
I understand "device", which is as per datasheet 1010000@ , where @ can be 0 or 1 based on if you write or read.
Cant understand subaddress, etc....

The subaddress is just another byte sent after sending the start followed by sla+w. If sending one byte, which is most likely used for an internal register address for the I2C slave, before sending a repeated start with the sla+r is not what your device requires, then simply copy, paste the i2CReceive(), call it what you want, and modify it to work as you require for your particular device.

For example, a read operation for a 24C256 looks like this:

Start
SLA+W
Address High Byte
Address Low Byte
Repeated Start
SLA+R
Data Byte From specified Address

Note, Acks, Naks, Stop not shown.

So, you could simply write a new version of i2cReceive with the appropriate parameters to handle this device.

@yellowboy_75: You really need to take more initiative if you want to be successful in your consulting business. Even at $15 per hour, I would expect you to be able to find, understand, and modify a function like this. If you are going to continue to work with I2C/TWI, you need to read and study all of the relevant documentation. Also, the best way to learn the AVR and related information is to read and respond to other's questions. Just jump right in! Good luck with your current project!

Tom

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Tom,
With a very little time and lots of work, i have t odepend on readymade codes....
Yesterday, i wrote my own implementation of 24c256 reading and writing......I know i can write but i cant get time to do it...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know what the competition is like in Pune. However, if you raised your rates would you then have more time to develop your client's solution without losing money? Are there many individuals and companies with a few employees doing embedded development? Is most of the development, by small firms, being done for local companies?

Tom

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

at $15 per hour for consulting, I can see why you have

Quote:
lots of work

but it seems a bit weird that as a consultant you merely provide
Quote:
have t odepend on readymade codes

AvrFreaks forums code and others work for that fee??? :shock:

surely you provide some ORIGINAL WORK as a "consulting business" ????

not trying to be mean spirited here ....just curious how "consultants "operate in India....

yellowboy_75....is the Atmel Dragon available in your country yet (since it was released in your part of the world first and that makes sense as the code development is inexpensive) ?
if so there probably are a few individuals on here that will pay you to send them some!!! :lol:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

$15 is the rate if i get international client. Which i have not got so far. Here in pune, we have small companies and individuals doing this job for local people. but the nature of ideas comup are too good. Now i am working on POS machine which will be sold locally at $100 - a dream price of my client. All and all, we get good enquiries of embedded development, but its India, not like other. Here we as small companies have to think of "survival" first and then earn more. As mine is a startup companiy, i have many roles to play. My software experience is of 8 years mainly on MS products. If for the project XYZ, i quote $15 per hr to international client then in local market it could be 3 times lesser than this.
Client development is not the only work i have, but have to llok out for sales of my own exsisting products too. so this pushes me to ask for some readymade library to save time.
And we Indian developers know very well that "If one knows how to copy a code from internet and where to paste in your project, is a good developer, at last the whole world looks at us as cost effective offshore development center". And if we have to be cost effective then we have to get things readymade.

YB

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yellowboy_75 wrote:
Now i am working on POS machine which will be sold locally at $100 - a dream price of my client.

That code you posted will be used in a commercial environment? :shock:

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!