Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

EEPROM issue PIC18f4520

Status
Not open for further replies.

haxan

New Member
HI,

earlier i had a function for reading/writing into internal EEPROM for PIC18F4480.

When i switched to PIC18F4520, the code is not working anymore.

From the datasheet of PIC18F4520 it says:

MOVLW DATA_EE_ADDR ;
MOVWF EEADR ; Data Memory Address to read
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access EEPROM
BSF EECON1, RD ; EEPROM Read
MOVF EEDATA, W ; W = EEDATA

from which i wrote the following C function:

unsigned char EEPROM_read(unsigned char eeprom_addr)
{
EEADR = eeprom_addr;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.RD = 1;
return EEDATA;
}

can anyone please guide what can i be doing wrong here?
 
I can't see anything wrong with your code. The only reason I can think of why this would not work is if a previous write hadn't finished, try adding while(EECON1bits.WR); to the start of your code.

Mike.
 
Thank you Pommie for the suggestion, i tried it and it but the problem still exists. However i noticed that if i comment everything in my main() function, it is still giving errors.

Attached is the errors (warnings) from simulation.

Can it be that i have to setup some register in main function.

It is giving all these errors even with main function such as

void main(void)
{
}
 

Attachments

  • Capture.JPG
    Capture.JPG
    162.7 KB · Views: 169
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top