Finally got it working. This was the link that finally did it for me: Needs to be translated from German: http://www.mikrocontroller.net/topic/278151 void main(void) { int x =3D 0; x =3D eeprom_read(0); //returns the 0x4142 eeprom_write(0x3355, 0); //writes 0x3355 to the first spot } int __attribute__ ((space(eedata))) eeData[250] =3D { //Default is: ABCDEFGH 0x4142, 0x4344, 0x4546, 0x4748, }; int eeprom_read(int index) { unsigned int offset; TBLPAG =3D __builtin_tblpage(&eeData); // Initialize EE Data page pointer offset =3D __builtin_tbloffset(&eeData); // Initizlize lower word of address offset +=3D index * sizeof(int); return __builtin_tblrdl(offset); // read EEPROM data } void eeprom_write(int data, int index) { unsigned int offset; NVMCON =3D 0x4004; // Set up NVMCON to erase one word of data EEPROM TBLPAG =3D __builtin_tblpage(&eeData); // Initialize EE Data page pointer offset =3D __builtin_tbloffset(&eeData); // Initizlize lower word of address offset +=3D index * sizeof(int); __builtin_tblwtl(offset, data); asm volatile ("disi #5"); // Disable Interrupts For 5 Instructions __builtin_write_NVM(); // Issue Unlock Sequence and Start Erase Cycle while(_WR); } Thanks for your help, John. On Thu, Apr 30, 2015 at 9:27 PM, Mitch wrote: > Thanks for the reply, John. > > I'm not sure where you found that PDF, and I've been googling for a while > but can't find anything about a PIC24F with Chapter 10 being EEPROM. It's > always Chapter 5. **shrug** > > But I still have a couple questions: > 1) How do I know what the offset is supposed to be? The MPLAB X EEPROM ta= b > shows the EEPROM starting at address 0x7ffe00 > 2) I tried using your code, and also the code straight from the > PIC24F32KA301 data sheet. Still nothing, I can't get past the first hump = of > writing data, let alone reading data. > > Am I missing something extremely obvious? > > This is driving me nuts! > > > int __attribute__ ((space(eedata))) eeData =3D 0x1234; > //Also tried: > //int __attribute__ ((space(eedata))) eeData[] =3D { 2, -1, -1, -1 }; > > void eeprom_write(int newData, uint offset) { > NVMCON =3D 0x4004; //Set up NVMCON to erase on= e > word of data EEPROM > > //Set up a pointer to the EEPROM location to be erased > TBLPAG =3D __builtin_tblpage(&eeData); //Initialize EE Data page > pointer > //Also tried without the "&" pointer deref > offset =3D __builtin_tbloffset(&eeData); //Initizlize lower word of > address > //Also tried without the "&" pointer deref > __builtin_tblwtl(offset, newData); //Write EEPROM data to write > latch > > asm volatile ("disi #5"); //Disable Interrupts For 5 > Instructions > __builtin_write_NVM(); //Issue Unlock Sequence & Sta= rt > Write Cycle > NVMCONbits.WREN =3D 1; //Also tried without this line > //This seems to stall the PIC indefinitely, so I just comment it out > and __delay_ms(1) afterwards > //while(NVMCONbits.WR =3D 1); //Optional: Poll WR bit t= o > wait for > //write sequence to complete > } > > int eeprom_read(uint offset) { > int data; > // Set up a pointer to the EEPROM location to be erased > TBLPAG =3D __builtin_tblpage(&eeData); //Initialize EE Data page > pointer > offset =3D __builtin_tbloffset(&eeData); //Initizlize lower word of > address > data =3D __builtin_tblrdl(offset); //Write EEPROM data to writ= e > latch > return(data); > } > > void main(void) { > int j =3D 0; > int z =3D 0; > for(j =3D 0; j < 10; j +=3D 2) { > z =3D ((j + 64) << 8) + (j + 64); > eeprom_write(z, j + 0x7ffe00); > //Also tried: > //eeprom_write(z, j); > __delay_ms(1); > } > } > > > > > On Thu, Apr 30, 2015 at 7:36 PM, John J. McDonough > wrote: > > > On Thu, 2015-04-30 at 17:34 -0600, Mitch wrote: > > > I'm looking for a way to write data to non-volitile memory. It seems, > > even > > > though they say you can write EEPROM, everyone say to do EEPROM > emulation > > > with Flash. > > > > > > All the examples I've found for 24F for some reason does not work. > > > I've tried these: > > > > > > http://www.ece.msstate.edu/courses/ece3724/main_pic24/docs/_p_i_c24_suppo= rt.html > > > http://www.microchip.com/forums/m707241.aspx > > > http://www.microchip.com/wwwAppNotes/AppNotes.aspx?appnote=3Den530593 > > > > > > The AN1095 PDF is quite a bit over my head and doesn't show any > examples. > > > > > > Does anyone know of a library that would work for all 24F chips? Or > > should > > > I just stick with an external chip? > > > > > > Writing EEPROM was SOOOO easy with PIC16!!! > > > > Well, once you figured it out it was! > > > > I found the examples in the FRM to work. It did seem to me that the > > data to write had to be global. I saw no reason to require that, but i= t > > didn't seem to work without it. My testing was on the KM2, but it look= s > > to me that the KA3 is identical save a few peripherals. > > > > Maybe you'll inspire me to try it with the KA3 and finish the chapter. > > > > --McD > > > > > > > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .