با سلام
من با استفاده از برنامه ی موجود در این وبلاگ :
http://powercontrol.mihanblog.com/extrapage/2126
برنامه زیر رو نوشتم.
در پروتئوس به درستی اجرا میشه ولی روی برد اصلیم که میبرم فقط صفر رو نمایش میده
بیت رایت پروتکتد و آدرسها رو هم به زمین وصل کردم.
راه حلی به ذهنم نمیرسه. ممنون میشم کسی راهنمایی و کمک کنه
اضافه شده در تاریخ :
کسی کار نکرده با این تراشه ؟؟!! :sad: :eek:
امیدم به این فروم بود :biggrin:
من با استفاده از برنامه ی موجود در این وبلاگ :
http://powercontrol.mihanblog.com/extrapage/2126
برنامه زیر رو نوشتم.
در پروتئوس به درستی اجرا میشه ولی روی برد اصلیم که میبرم فقط صفر رو نمایش میده
بیت رایت پروتکتد و آدرسها رو هم به زمین وصل کردم.
راه حلی به ذهنم نمیرسه. ممنون میشم کسی راهنمایی و کمک کنه

[code=cpp]/#include <mega32.h>
/* the I2C bus is connect to PORTB */
/* the SDA signal is bit 0 */
/* the SCL signal is bit 1 */
#include <i2c.h>
#include <delay.h>
#include <stdio.h>
// Graphic LCD functions
#include <glcd.h>
// Font used for displaying text
// on the graphic LCD
#include <font5x7.h>
#include <stdlib.h>
#define EEPROM_BUS_ADDRESS 0XA0
int data;
char str[15];
/* function eeprom_read for read
a byte from the external eeprom*/
unsigned char eeprom_read(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;
}
/* function eeprom_write for writ
a byte to the external eeprom*/
unsigned char eeprom_write(unsigned char address,unsigned char data)
{
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_write(data);
i2c_stop();
delay_ms(20); // 10 ms delay to complete the write opertion
}
void main(void)
{
// Declare your local variables here
// Graphic LCD initialization data
GLCDINIT_t glcd_init_data;
// Specify the current font for displaying text
glcd_init_data.font=font5x7;
// No function is used for reading
// image data from external memory
glcd_init_data.readxmem=NULL;
// No function is used for writing
// image data to external memory
glcd_init_data.writexmem=NULL;
glcd_init(&glcd_init_data);
DDRA=0XFF;
/* initialize the i2c bus */
i2c_init();
eeprom_write(0x00,0xAB);
PORTA= eeprom_read(0x00);
data=eeprom_read(0x00);
//SHow the result on GLCD
itoa(data,str);
glcd_outtextxy(14,6,str);
while(1);
}[/code]
/* the I2C bus is connect to PORTB */
/* the SDA signal is bit 0 */
/* the SCL signal is bit 1 */
#include <i2c.h>
#include <delay.h>
#include <stdio.h>
// Graphic LCD functions
#include <glcd.h>
// Font used for displaying text
// on the graphic LCD
#include <font5x7.h>
#include <stdlib.h>
#define EEPROM_BUS_ADDRESS 0XA0
int data;
char str[15];
/* function eeprom_read for read
a byte from the external eeprom*/
unsigned char eeprom_read(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;
}
/* function eeprom_write for writ
a byte to the external eeprom*/
unsigned char eeprom_write(unsigned char address,unsigned char data)
{
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_write(data);
i2c_stop();
delay_ms(20); // 10 ms delay to complete the write opertion
}
void main(void)
{
// Declare your local variables here
// Graphic LCD initialization data
GLCDINIT_t glcd_init_data;
// Specify the current font for displaying text
glcd_init_data.font=font5x7;
// No function is used for reading
// image data from external memory
glcd_init_data.readxmem=NULL;
// No function is used for writing
// image data to external memory
glcd_init_data.writexmem=NULL;
glcd_init(&glcd_init_data);
DDRA=0XFF;
/* initialize the i2c bus */
i2c_init();
eeprom_write(0x00,0xAB);
PORTA= eeprom_read(0x00);
data=eeprom_read(0x00);
//SHow the result on GLCD
itoa(data,str);
glcd_outtextxy(14,6,str);
while(1);
}[/code]
اضافه شده در تاریخ :
کسی کار نکرده با این تراشه ؟؟!! :sad: :eek:
امیدم به این فروم بود :biggrin:
دیدگاه