HEF and pragma EEDATA

14 views
Skip to first unread message

David VB

unread,
Feb 1, 2026, 8:30:27 AM (12 days ago) Feb 1
to jallist
Hi there,

I'm using a pic16f1768.
To reduce size of the program, I would like to push 100 constants bytes into HEF.

Note that HEF already contains 2 words at adresses 0F80h and 0F82h.
So, I would like to store a set of 100 constant bytes in HEF, but starting at 0F84h.

1°) will PRAGMA EEDATA work with HEF
2°) how can I tell the compiler to put my 100 bytes starting at 0F48h (otherwise, it starts at the beginning of HEF, at 0F80h)

Any help appreciated.

David

David VB

unread,
Feb 1, 2026, 9:17:46 AM (12 days ago) Feb 1
to jallist
Small correction: At question 2, I'd like my HEF data being placed starting at 0F84h (as stated above) and not 0F48h

Rob CJ

unread,
Feb 1, 2026, 11:52:45 AM (12 days ago) Feb 1
to jallist
Hi David,

The compiler does not support HEF (I wonder if a PICKit programmer supports it) but there is a HEF library that you can use. 

You can set the address where to start writing your HEF data, see the sample file for HEF.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens David VB <pinhe...@gmail.com>
Verzonden: zondag 1 februari 2026 14:30
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] HEF and pragma EEDATA
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallist/df3ce2c6-23df-4184-924b-73d8f1a0015en%40googlegroups.com.

pinhe...@gmail.com

unread,
Feb 1, 2026, 12:51:58 PM (12 days ago) Feb 1
to jallist
Thanks Rob, but this will not help, since those are constants i need to store ( an array of 10 x 10 bytes)

I am short on program memory and RAM, so calling 100 times the data_hef_write will not help

I have no other choice than to find a way to store those 100 bytes in another part of the memory

An external memory is no-go too, since the pcb is already made....

Could the "AT" directive help ?



Rob CJ

unread,
Feb 1, 2026, 1:17:01 PM (12 days ago) Feb 1
to jal...@googlegroups.com
Hi David,

I am not sure if HEF data is erased when you erase a PIC. If not you can try the following.
  1. Erase the PIC
  2. Write a small program that writes the required data to HEF
  3. Erase the PIC. In the PICKit3 software you can disable the erasing of the EEPROM. Disable that erase.
  4. Program the PIC with the final software.

Not sure if it works.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens pinhe...@gmail.com <pinhe...@gmail.com>
Verzonden: zondag 1 februari 2026 18:51
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] HEF and pragma EEDATA
 

pinhe...@gmail.com

unread,
Feb 1, 2026, 2:34:38 PM (11 days ago) Feb 1
to jal...@googlegroups.com
Good idea !

I will try this !  
It could take some time, but I will post the results

Thanks for the tip !



pinhe...@gmail.com

unread,
Feb 1, 2026, 3:10:14 PM (11 days ago) Feb 1
to jal...@googlegroups.com
If Gemini is right (see screenshot), it concurs with your proposal 



1000014509.jpg

Rob CJ

unread,
Feb 2, 2026, 1:20:22 PM (11 days ago) Feb 2
to jal...@googlegroups.com
Hi David,

Oh, I used HI for this solution 🙂.

I wonder how often JAL users would use a pragma hef like a pragma eeprom since the latter always starts on the first address of the EEPROM and if I understood you correctly you wantes to start at a different address?

I can imagine that the pragma eeprom is quite isolated from the rest of the compiler code (not checked this) and maybe it would be possible to add a new pragma hef but the question remains if it is worth the effort since you could also - if you have sufficient flash memory - just initialize it from your program.

Kind regards,

Rob


Verzonden: zondag 1 februari 2026 21:10
Aan: jal...@googlegroups.com <jal...@googlegroups.com>

Rob CJ

unread,
Feb 4, 2026, 12:31:31 PM (9 days ago) Feb 4
to pinhe...@gmail.com, jallist
Hi David (added Jallist for sharing this information),

Good to know that if you want to you HEF, the way to do that is then using the JAL HEF library since HEF information is not mentioned separately in the Microchip XML description of the PIC and so not possible to get this information in the device file.

Kind regards,

Rob


Van: pinhe...@gmail.com <pinhe...@gmail.com>
Verzonden: woensdag 4 februari 2026 14:25
Aan: Rob CJ <rob...@hotmail.com>

Onderwerp: Re: [jallist] HEF and pragma EEDATA
 
Hi Rob,

I think I understand why there is no explicit mention to hef in the device files from microchip :
Because hef is totally part of the code memory.
It's a pity they do not mention it anyway, but it is like it is.....

On the other hand, your solution ( first a program to initialize, then the main application with memory protect of the hef) is probably the best when variables in hef need to have an initial value.

In my case, however, except for the two first words, the rest of my data (100 bytes) are constants.  Therefore, they are hardcoded in the code memory.   My will to put them in hef was only due to the fact that that is what I've done if the pic had a classic eeprom....

Should I have looked at it from a more accurate perspective (hef is NOT equivalent to eeprom), I would not have tried so hard to use hef.

Anyway, after research on the net, I see that the whole notion of "hef is part of the code memory, and not a separate zone as eeprom is" is confusing for a lot of people.

Hope this discussion will help others....

Anyway, thanks for the good advices



Le 3 février 2026, à 19:32, Rob CJ <rob...@hotmail.com> a écrit:


Hi David,

If we would like to add a pragma HEF, the start address of HEF must be in the device file. The device files are generated via a Python script that uses the XML description of the PIC from Microchip. Since HEF was never checked you will also not find it in the device file.

I had a short look at the PIC16F1455 which has HEF that goes from address 0x1F80 - 0x1FFF and I checked the XML file from Microchip but I could only find the total Program space including the HEF space but not a separate HEF address. It looks like this:

<edc:CodeSector edc:beginaddr="0x0" edc:endaddr="0x800" edc:issection="true" edc:regionid="page0" edc:sectiondesc="ROM code space - page0" edc:sectionname="PROG0"/>
<edc:CodeSector edc:beginaddr="0x800" edc:endaddr="0x1000" edc:issection="true" edc:regionid="page1" edc:sectiondesc="ROM code space - page1" edc:sectionname="PROG1"/>
<edc:CodeSector edc:beginaddr="0x1000" edc:endaddr="0x1800" edc:issection="true" edc:regionid="page2" edc:sectiondesc="ROM code space - page2" edc:sectionname="PROG2"/>
<edc:CodeSector edc:beginaddr="0x1800" edc:endaddr="0x2000" edc:issection="true" edc:regionid="page3" edc:sectiondesc="ROM code space - page3" edc:sectionname="PROG3"/>

So the total ROM space is devided over PROG0 --- PROG3 from 0x0000 to 0x1FFF (end address 0x2000) but no special space for HEF. I am not sure if there is something else mentioned in this XML file indicates anything which is HEF related but I could not find it. If not, it is not possible to generate a device file with the HEF address and so would the compiler not be able to generated some hex information using a pragma hef.

If you in the xml file of a PIC that has EEPROM, you see this:

<edc:EEDataSector edc:beginaddr="0xF000" edc:endaddr="0xF100" edc:issection="true" edc:regionid="eedata" edc:sectiondesc="Data EEPROM" edc:sectionname="DEEPROM"/>

So here we can retrieve the start address and an end address of the EEPROM.

Kind regards,

Rob



Van: Pinhead <pinhe...@gmail.com>
Verzonden: dinsdag 3 februari 2026 15:09
Aan: Rob CJ <rob...@hotmail.com>

Onderwerp: Re: [jallist] HEF and pragma EEDATA
 

Hi,


About the adress, it's not a problem: in my application, I will use the first 4 bytes (2 words) as parameters set during runtime.    That's why my array of data only starts at 0x0F84.   


I had a look in the device file for a pic with classic EEPROM, and there is a pragma eeprom in it, but not for pic's with HEF.


In the meantime, I found an asm example of how to initialize the hef in the source code ( https://www.microcontroller.it/english/Tutorials/PIC/HEF.htm ) :


; HEF memory preload
   #ifdef __16F1508
HEFDATA CODE 0F80h
   #endif
   #ifdef
__16F1509
HEFDATA CODE 1F80h
   #endif
   #ifdef
__16F1507
HEFDATA CODE 0780h
   #endif

DA 60h, 0, 99h, 9, 40h, 03h, 0, 0 ;8 bytes
DA "MICROCONTROLLER.IT@ 2015"     ;24 bytes - tot 32 bytes


The "CODE" directive specifies the start adress of the HEFDATA, depending of the pic used.
The DA directive is then used to initialize the data starting at that adress.


Is there any way to do the same in jal ?
(Equivalent to tell the compiler to "Put the following data DA starting at the CODE adress".
The result is that that data will be initialized during programming time and will not take up any space neither in RAM nor in program memory.




Le 02-02-26 à 19:20, Rob CJ a écrit :
You received this message because you are subscribed to a topic in the Google Groups "jallist" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jallist/6_c4hoodm_U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jallist+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallist/AM0PR02MB4052B8C57BF0EA046A7DEA83E69AA%40AM0PR02MB4052.eurprd02.prod.outlook.com.
Reply all
Reply to author
Forward
0 new messages