View previous topic :: View next topic |
Author |
Message |
birumher
Joined: 28 Apr 2004 Posts: 10
|
I2C EEPROM Simulation |
Posted: Fri Jun 30, 2006 2:30 am |
|
|
Hi, I want to simulate 24C32 I2C EEPROM with Proteus, unfortunately it doesnt work :( . I write 12 to 5. address and when I read the 5. address it is allways 255.
Where is the mistake ? In my code or my circuit ?
here is my circuit,
and here is my code,
Code: |
/////////////////////////////////////////////////////////////////////////
//// MAIN.C ////
//// ////
/////////////////////////////////////////////////////////////////////////
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
#use delay(clock=4000000)
#include <lcd.c>
#include <2432.c>
void main()
{
BYTE data;
BYTE data2;
long int addr;
init_ext_eeprom();
lcd_init();
lcd_gotoxy(1,1);
data = 12;
data2 = 12;
addr=5;
// write 12 to 5. byte
write_ext_eeprom(addr, data);
printf(lcd_putc,"write ad.\%02Lu data \%02u", addr, data);
delay_ms(40);
while (1)
{
lcd_gotoxy(1,2);
// read 5. byte
data2 = read_ext_eeprom(addr);
lcd_gotoxy(1,2);
printf(lcd_putc,"read ad.\%02Lu data \%02u", addr, data2);
delay_ms(1000);
}
}
|
i use 2432 driver..
Last edited by birumher on Fri Jun 30, 2006 4:20 am; edited 1 time in total |
|
|
Ttelmah Guest
|
|
Posted: Fri Jun 30, 2006 3:14 am |
|
|
First of all, use the group edit function, and remove the CCS code from your post. Note that this group is available for 'public' viewing, and that you are in breach of the distribution terms by posting it...
The code looks as thogh it ought to work. There is a slight 'oddity', in the circuit, in that you show the MCLR line pulling to Vcc, while the I2C lines pull to Vdd. Do you have a Vcc line, or a Vdd line?.
Best Wishes |
|
|
birumher
Joined: 28 Apr 2004 Posts: 10
|
|
Posted: Fri Jun 30, 2006 4:48 am |
|
|
OK Ttelmah thank you for your warning. I changed Vcc and Vdd lines according eeprom and pic pins. But it is still the same result. Now I think that it is a simulation problem. I will build the circuit... |
|
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Fri Jun 30, 2006 5:26 am |
|
|
Plus, look at the sim log for the I2C device. It's fairly verbose and gives you alot of detail about what it's processing. |
|
|
birumher
Joined: 28 Apr 2004 Posts: 10
|
|
Posted: Sun Jul 02, 2006 6:35 am |
|
|
I builded the circuit. It works fine .
(I think that proteus can't simulate 24c32.) |
|
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Sun Jul 02, 2006 2:13 pm |
|
|
Proteus simulates a 24C32A or a 24LC32A just fine. |
|
|
birumher
Joined: 28 Apr 2004 Posts: 10
|
|
Posted: Sun Jul 02, 2006 2:47 pm |
|
|
rberek wrote: | Proteus simulates a 24C32A or a 24LC32A just fine. |
Could you please post an example?
Maybe my version has some problems.
I am using 6.9 sp4... |
|
|
|