View previous topic :: View next topic |
Author |
Message |
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 42
|
PIC18F66K22 EEPROM Functions |
Posted: Tue Feb 04, 2025 8:13 am |
|
|
I am writing a code whereby I need more than 256 bytes of data to store.
I have checked the datasheet and it suggests the PIC18F66K22 has 1024 Bytes of storage.
However, when I am using the library function write_eeprom, it does not write beyond 256 bytes and starts overriding it.
i.e. if I write ADD = 10, Data = 56; write_eeprom (ADD,DATA), it works fine. But if I try to write at the address 300 with Data = 56, it changes the data of address (300-256).
PS: I have also changed the header file section as below:-
Code: | // EEPROM Prototypes:
/*
#ifndef __EEADDRESS__
#if getenv("DATA_EEPROM")>256
#define __EEADDRESS__ unsigned int16
#else
#define __EEADDRESS__ unsigned int8
#endif
#endif
*/
#define __EEADDRESS__ unsigned int16 |
Any direction? _________________ MVadukul |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9372 Location: Greensville,Ontario
|
|
Posted: Tue Feb 04, 2025 8:36 am |
|
|
I don't have that PIC, never used the write_eeprom()...
but
since your PIC has 1024 bytes of storage, I'd always use unsigned int16 for the address.
It may be 'something' in the library has defaulted to 8 bit.
Maybe your code uses the same variable name and it's 8 bit ?
I don't know but pretty sure someone who has used this will reply soon ! |
|
|
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 42
|
PIC18F66K22 EEPROM Functions |
Posted: Tue Feb 04, 2025 10:26 am |
|
|
The problem is solved now.
The issue was that the variable I used was 16 bit unsigned integer, but the offset which was passed to obtain the storage address was unsigned 8 bit integer.
I was storing from offset 119 to 329. However, when the counter went beyond 255, it turned 0.
i.e. unsigned 16 bit int a = offset (119) + required location (this was unsigned 8 bit integer);
The above should work technically as the stored variable is larger in size but it didn't work. But once I made the variable which was passed into the loop as unsigned 16 bit integer as well, it started working correctly. _________________ MVadukul |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9372 Location: Greensville,Ontario
|
|
Posted: Tue Feb 04, 2025 11:36 am |
|
|
whew you FOUND it ! great !!!
sometimes little problems can cause BIG headaches. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19649
|
|
Posted: Tue Feb 04, 2025 12:43 pm |
|
|
Classic.
Well done finding it. Flag the thread as solved please. |
|
|
|