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.

help please memory problem

Status
Not open for further replies.
You've already added a short assembler routine in your C function, so why not do ALL the EEPROM write in assembler?, there's an example in the datasheet, and it seems pointless writing part of it in C and part in assembler?.
 
Thanks guys its working now, just labelled the memory address in hex wrong they should be 0x40 and 0x00.

later
 
please post up your working code, and note what compiler it is for. then other people can make use of the code if they find this thread by searching, or if someone links them to it :)
 
Here is the complete code for writing into a PIC18F4620 EEPROM using MPLAB C18 compiler

void writeDataEE (unsigned int data)
{
EEADR = 0x10;//address
EEADRH = 0x02;//address
EEDATA = data;
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
INTCONbits.GIE=0;
_asm
MOVLW 0x55
MOVWF EECON2,0
MOVLW 0xAA
MOVWF EECON2,0
_endasm
EECON1bits.WR=1;
while (EECON1bits.WR == 1){};
INTCONbits.GIE=1;
EECON1bits.WREN = 0;
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top