Proton BASIC Community

Proton (Positron) => Lounge => Topic started by: trastikata on Jan 09, 2024, 11:16 AM

Title: Microchip HEX file format and EEPROM one data byte?
Post by: trastikata on Jan 09, 2024, 11:16 AM
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?
Title: Re: Microchip HEX file format and EEPROM one data byte?
Post by: Dompie on Jan 09, 2024, 11:55 AM
This has been the case for many years. I thought that every odd number of bytes in Edata is followed by a $00.

Johan
Title: Re: Microchip HEX file format and EEPROM one data byte?
Post by: tumbleweed on Jan 09, 2024, 01:07 PM
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
Title: Re: Microchip HEX file format and EEPROM one data byte?
Post by: trastikata on Jan 09, 2024, 01:21 PM
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.