Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with EEPROM and PIC18F2520

Status
Not open for further replies.

lindodv

Junior Member level 1
Joined
Jul 4, 2014
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
121
Hi guys, I have two problems:
1) LEDs are not blinking.
2) I can see a lot of errors in the simulator(Protus)
how can I solve this Problems with EEPROM?
I'm using mikroc for PIC.
thanks a lot.
Code:
void main(){


    PORTC = 0;
    TRISC = 0;

while (1) {

    EEPROM_Write(2,0b11110000); // Write some data to EEPROM address 2
    EEPROM_Write(3,0b00001111); // Write some data to EEPROM address 3



    PORTC = EEPROM_Read(2); // Read data from EEPROM address 2 and display it on PORTC

    Delay_ms(1000);

    PORTC = EEPROM_Read(3); // Read data from EEPROM address 3 and display it on PORTC

    Delay_ms(1000);

    }
}

00430888790138846386.png
 
Last edited by a moderator:

Put a small delay between the second EEPROM_Write and the first EEPROM_Read:
Code:
    ..........
    EEPROM_Write(3,0b00001111); 
    Delay_ms(20); // !!!!!!!!!!!!!!
    PORTC = EEPROM_Read(2);
    ..........
 
It takes 5mS to write to the EEPROM or you can monitor EECON1,WR bit. You will also need to pause between the two EEPROM writes.
 
It takes 5mS to write to the EEPROM or you can monitor EECON1,WR bit.
Yes, it's true.

You will also need to pause between the two EEPROM writes.
No. The mikroC EEPROM_Write function also examines the EECON1,WR bit but at startup (not at end). It should therefore be a delay before the EEPROM read.
 

thanks, now LEDs are blinking but error still exist..
how can I modify EECON1 for removing the simulator errors?(I couldn't modify EECON1 by enabling and disabling WRERR(1)-WREN-WR-RD !)
 

Please post the ENTIRE project folder after compiled (with c, cfg, mcppi and the log, asm, lst ... files created by the compiler) and also your Proteus DSN file (a non-8.x version, max. v7.10).
 

thanks, now LEDs are blinking but error still exist..
how can I modify EECON1 for removing the simulator errors?(I couldn't modify EECON1 by enabling and disabling WRERR(1)-WREN-WR-RD !)

Read the data, you cannot set the EECON1 registers as if they were RAM. you can set the registers but not reset them. (apart from WREN)

WR: Write Control bit
1 = initiates a write cycle. (The bit is cleared by hardware once write is complete. The WR bit
can only be set (not cleared) in software.
0 = Write cycle to the data EEPROM is complete
 
thanks guys, I found my problem here"To avoid this warning on Proteus, you have to open the "Debug" menu, click on "Configure Diagnostics...", and at the bottom of the window that appears change to "Log from 0 for 0 seconds" instead of "Log from 0 for 60 seconds". Thus you can simulate without warnings and your EEPROM will be updated according to the program."
 

thanks guys, I found my problem here"To avoid this warning on Proteus, you have to open the "Debug" menu, click on "Configure Diagnostics...", and at the bottom of the window that appears change to "Log from 0 for 0 seconds" instead of "Log from 0 for 60 seconds". Thus you can simulate without warnings and your EEPROM will be updated according to the program."

Why would you want to do this? You may have masked Proteus's error messages, but it won't work on the actual hardware. The Proteus simulation of the EEPROM (EERAM) works as advertised and any error messages are correct. I have a complex program running that uses the EEPROM extensively and I have experienced no problems or error messages.

Note the EEPROM's contents in Proteus are permanently saved when you save the design, otherwise you will lose them when exiting the program.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top