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.

PIC32 Internal EEPROM

Status
Not open for further replies.

rmrps

Member level 2
Joined
Oct 4, 2011
Messages
42
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,635
Hi Friends I am Using PIC32MX360F512L Controller I am trying to store the data in internal eeprom but i don't know how to do it my example code is here please anybody tell me how to store and read the data from internal eeprom in pic32 series in datasheets mention for erasing flash memory and writing into flash memory and no details available for read the data from eeprom please give me the example code for erase,write,and read the data from pic32mx360f512l internal eeprom thanks in advance

Code:
int main()
    {
      NVMUnlock (0x0000C001);
      Buffer[0]=0xBF80F400;
      NVMErasePage(Buffer);
      NVMWriteWord(Buffer,0x06);
       NVMReadWord(Buffer);
    }


unsigned int NVMUnlock (unsigned int nvmop)
{


	unsigned int status;
	asm volatile ("di %0" : "=r" (status));
	// Enable Flash Write/Erase Operations and Select
	// Flash operation to perform
	NVMCON = nvmop;
	// Write Keys
	NVMKEY = 0xAA996655;
	NVMKEY = 0x556699AA;
	// Start the operation using the Set Register
	NVMCONSET = 0x8000;
	// Wait for operation to complete
	while (NVMCON & 0x8000);
	// Restore Interrupts
	if (status & 0x00000001)
	asm volatile ("ei");
	else
	asm volatile ("di");
	// Return NVMERR and LVDERR Error Status Bits
	return (NVMCON & 0x3000);
}


unsigned int NVMErasePage(void* address)
	{
	unsigned int res;
	// Set NVMADDR to the Start Address of page to erase
	NVMADDR = (unsigned int) address;
	// Unlock and Erase Page
	res = NVMUnlock(0x4004);
	// Return Result
	return res;
   }

unsigned int NVMWriteWord (void* address, unsigned int data)
   {
	unsigned int res;
	// Load data into NVMDATA register
	NVMDATA = data;
	// Load address to program into NVMADDR register
	NVMADDR = (unsigned int) address;
	// Unlock and Write Word
	res = NVMUnlock (0x4001);
	// Return Result
	return res;
  }

unsigned int NVMReadWord (void* address)
   {
	unsigned int res;
	// Load data into NVMDATA register
	// Load address to program into NVMADDR register
	NVMADDR = (unsigned int) address;
	// Unlock and Write Word
    res=NVMADDR;
	// Return Result
	return res;
  }
 
Last edited by a moderator:

skogsjanne

Full Member level 3
Joined
May 28, 2009
Messages
172
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,308
Activity points
2,084
Sorry, but I have no details. Usually the application notes are pretty good so maybe you should try to read them...
 

Graham1904

Junior Member level 1
Joined
Aug 13, 2009
Messages
17
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Location
Durban
Activity points
1,372
PIC32 has no internal EEPROM it is only emulated using the DEE libraries.
 

poorchava

Advanced Member level 1
Joined
May 21, 2009
Messages
429
Helped
71
Reputation
142
Reaction score
71
Trophy points
1,318
Location
Wrocław, Poland
Activity points
4,780
You can try storing informations in internal flash memory, because PIC32MXs have self programming capability, but beware: program flash has lower write endurance than normal EEPROM
 

Graham1904

Junior Member level 1
Joined
Aug 13, 2009
Messages
17
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Location
Durban
Activity points
1,372
You can try storing informations in internal flash memory, because PIC32MXs have self programming capability, but beware: program flash has lower write endurance than normal EEPROM

Has anyone tried using the DEE libraries as I am battling even to store one byte of data :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top