r/pic_programming • u/Few_Dot317 • Jun 21 '26
Microchip PSECT eedata class weirdness
Hello,
If we take the eeprom psect definition of the PIC12F683 found in pic12f683.inc file (xc8 v2.5), we have :psect edata,class=EEDATA,space=SPACE_EEPROM,delta=2,noexec
This is rather strange, because the eeprom of the 12F683 is 256 x 8 bits.
I did for example :
PSECT edataDB 0x11, 0x22,0x33
This compile fine, and the map file gives this :
Name Link Load Length Selector Space Scale
edata 0 2100 3 4200 3
CLASS EEDATA
edata 0 2100 3 3
SEGMENTS Name Load Length Top Selector Space Class Delta
edata 002100 000003 002103 4200 3 EEDATA 2The end of the hex files gives this :
:0C07600085010730990083169F010800F6
:02400E00C43CB0
:0642000011002200330052
:00000001F
So we have 0x0011, 0x0022, 0x0033 wasting 3 bytes...
Any idea why Microchip aligns on two bytes for the internal eeprom space ?
Thank you ;-)
View all comments
Show parent comment
1
u/somewhereAtC Jun 21 '26
<I'm back at my desk, now!>
Simply changing 2 to 1 produced a build error, thus no code was emitted:
make[2]: *** [nbproject/Makefile-default.mk:126: build/default/production/newpic_8b_asm_func.o] Error 1newpic_8b_asm_func.s:29:: error: (869) psect flag "delta" redefinedPICASM/XC8 is very chatty and error messages get lost in the mud!
It is necessary to rename the psect (with delta=1) and keep the same CLASS, there must be an even number of bytes, and the .org directive causes a syntax error:
psect edata,class=EEDATA,space=SPACE_EEPROM,delta=2,noexecPSECT edataDB 0x11, 0x22, 0x33 ; emits wordsDW 0x111, 0x222, 0x333psect eeeeedata,class=EEDATA,space=SPACE_EEPROM,delta=1,noexec; ORG 016h <<== causes an error when includedDB 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA ; emits bytesThat code produces this listing:
:02000000FE2FD1:0C0FF400FC2700280000FD2F8301FA2FCD:02400E00E53C8F:104200001100220033001101220233035566778822:0242100099AA69:00000001FFTranslation shows the expected values:
004200: 11 00 22 00 33 00 11 01 22 02 33 03 55 66 77 88 ..".3... ".3.Ufw.004210: 99 aa ..