Problem with 16f876 and external eeprom (i2c)

Status
Not open for further replies.

dibe84

New Member
Hi, I've a problem with a Microchip PIC16F876.
I'm trying to write to an external eeprom (24LC32A) with the following circuit:

https://digilander.libero.it/dibe84/cirORb.JPG

and the following source code (written in C18 and compliled with PICCLITE):


here, you can find the inclued files
https://digilander.libero.it/dibe84/include.rar
(I think they works, I find them here: www.jofi.it/fiser)

The program write only few values on the external eeprom (for example:
ExtEpromWrite(idDevice1, 0x0001, 0x11); // Scrive dato
ExtEpromWrite(idDevice1, 0x0002, 0x12); // Scrive dato
ExtEpromWrite(idDevice1, 0x0003, 0x13); // Scrive dato

it writes on the last value (0x13)....
)

But it isn't the only problem because the program not always ends: usually restarts before the end of the it (I understand it can't see the sequence of lamping leds by the end of program). In the other hand if I disconnect the SDA or SCL pin the program always ends.

You can help me?!?!?

(sorry for my bad english, but I'm italian)

bye!!
 
I think no, because I've tested with the WDT and BROWNOUTRESET in both configurations (on/off).
 
buena sera,

I see several things which are suspicious.

First, there is no ending brace of the main function.
Second, what do you think happens when main() returns? There is no operating system to return to! You need to have some kind of "do forever" loop in main(). Something like:

Code:
    while(1)
    { }
or
    for(;;)
    {  }
or
    do
    {  } while(1)

Alternately if you can check the compiled code you can find out what happens when Main() returns. In the best case there should be a "loop: goto loop" instruction there. The alternative is too horrible to contemplate.

Ciao
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…