CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F4550 with 24LC16 EEPROM write and read only once

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mheber



Joined: 13 Jan 2012
Posts: 3
Location: Germany

View user's profile Send private message

PIC18F4550 with 24LC16 EEPROM write and read only once
PostPosted: Fri Feb 10, 2012 3:51 am     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 10, 2012 2:49 pm     Reply with quote

Post a short test program that shows the problem. Cut out all the glcd
stuff. Put in a #use rs232() statement and use printf to display the
results. Then tell us what you saw.

Also post your CCS compiler version.
mheber



Joined: 13 Jan 2012
Posts: 3
Location: Germany

View user's profile Send private message

PostPosted: Sun Feb 12, 2012 3:57 am     Reply with quote

Hello PCM programmer,
thanks for your help. I don't know why but now every thing works as expected. I guess a bad connection on the breadboard. I use the actual compiler version 4.129. BTW there is a error in the 2416.c:
"#define EEPROM_SIZE 1024" is wrong because it's a 16k-bit (2048x8)
EEPROM.

Best Regards
Michael
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group