On 18 Sep 2006 05:33:09 -0700, "tanu" <tanumeister@gmail.com> wrote:
>when i m reading my eeprom i m geting nothing
>i think that my code is either not able to generate the clock pulse or
>not able to write the data into eeprom
>i m not getting ,how to genrate the clk ?
>
===SNIP===
>/* write a byte to the EEPROM */
>void eeprom_write(unsigned char EEPROM_BUS_ADDRESS,unsigned char
>address, unsigned char data)
===SNIP===
>void main(void)
>{
===SNIP===
>/* write the byte 55h at address AAh */
>eeprom_write(0x0182,0x00aa,0x43);
===SNIP===
^^^^^^ ^^^^
I smell fish.
--
Dan Henry
Reply by tanu●September 18, 20062006-09-18
Hi all
I am using ATmega128 controller and using i2c bus eeprom to increase
its memory space .
I have i2c header file in my codevision avr and i used them and change
that accordingly
but when i m reading my eeprom i m geting nothing
i think that my code is either not able to generate the clock pulse or
not able to write the data into eeprom
i m not getting ,how to genrate the clk ?
#include <mega128.h>
// I2C Bus functions port D
#asm
.equ __i2c_port=0x12
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
#include <delay.h>
// Declare your global variables here
/* read a byte from the EEPROM */
unsigned char eeprom_read(unsigned char EEPROM_BUS_ADDRESS , unsigned
char address)
{
unsigned char data;
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS | 1);
data=i2c_read(0);
i2c_stop();
return data;
}
/* write a byte to the EEPROM */
void eeprom_write(unsigned char EEPROM_BUS_ADDRESS,unsigned char
address, unsigned char data)
{
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_write(data);
i2c_stop();
/* 10ms delay to complete the write operation */
delay_ms(10);
}
unsigned char eeprom *ptrom;
void main(void)
{
unsigned char i;
// Declare your local variables here
// I2C Bus initialization
i2c_init();
ptrom=0x0000;
/* write the byte 55h at address AAh */
eeprom_write(0x0182,0x00aa,0x43);
PORTB=0X00;
delay_ms(500);
PORTB=0XFF;
delay_ms(500);
/* read the byte from address AAh */
i=eeprom_read(0x0182,0x00aa);
*ptrom=i;
// Place your code here
while (1)
{
};
}
need ur help thanx