News:

Let's find out together what makes a PIC Tick!

Main Menu

Microchip HEX file format and EEPROM one data byte?

Started by trastikata, Jan 09, 2024, 11:16 AM

Previous topic - Next topic

trastikata

Hello all,

I am writing a bootloader but never before had to write in the EEPROM for custom bootloaders, now I do and I came to a particular problem with the EEPROM.

If you add one byte of data to the EEPROM, the resulting hex file line will be extended to 2 bytes and filled with 00.

QuoteEData $55
:0200000400F00A
:020000005500A9

However if you add a second data byte equal to zero you will get the same code.

QuoteEData $55, $00
:0200000400F00A
:020000005500A9

So my question is is there a way to differentiate if two bytes are being written in the EEPROM or one byte?

Dompie

This has been the case for many years. I thought that every odd number of bytes in Edata is followed by a $00.

Johan

tumbleweed

The assembler (mpasm) will always emit an even number of bytes, so there's no way to distinguish between the two cases. That's because eeprom data is put into the hex file the same as code would be, and code is always an even number of bytes. It's just located at a special offset, which depends on the device.

310000                00792     ORG 0X310000
310000 0001           00793     DB  0X01

trastikata

Thanks for the answers.

I did not expect EEPROM to behave this way since self-programming allows for writing odd number of bytes in the EEPROM.