mheber
Joined: 13 Jan 2012 Posts: 3 Location: Germany
|
PIC18F4550 with 24LC16 EEPROM write and read only once |
Posted: Fri Feb 10, 2012 3:51 am |
|
|
Hello @all, I have the problem, that I can write and read data in the EEPROM only once while my program is running. All subsequent writings and readings are ignored.
Code: |
#include <18F4550.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use i2c(master, sda=PIN_C6, scl=PIN_C7, stream=EEP, force_sw)
#use i2c(master, sda=PIN_E1, scl=PIN_E2, stream=TMP, force_sw)
........
void main(void)
{
char buf[64];
int8 i;
init_ext_eeprom();
enable_interrupts(INT_SSP);
enable_interrupts(GLOBAL);
glcd_init(ON);
delay_ms(200);
glcd_fillScreen(off); // Clear the display
i = 0;
while (true)
{
if (i == 8);
i = 0;
write_ext_eeprom(i, (i+1) * 8);
sprintf (buf, "T=%Lu", GetTemp());
glcd_rect (12, 8, 18*5, 8+7, yes, off);
glcd_rect (12, 24, 18*5, 24+7, yes, off);
glcd_text57 (0, 8, buf, 1, on);
sprintf (buf, "M=%u", read_ext_eeprom(i));
glcd_text57 (0, 24, buf, 1, on);
i++;
delay_ms(200);
}
}
|
I've used the same EEPROM-Routines like in 2416.c only modified for using streams. As I tested with original 2416.c without the second I2C-Port the result was the same. I got only the result of the 1st write (8).
With hard coding the read address I found out, that the other addresses are not written. Only the first write and read occurs all subsequent operations are ignored. I have a 24LC16B connected to the 18F4550 with 2.2k pull up resistors. Do anyone know about this strange effect?
Thanks in advance.
Michael |
|