08-05-2022 03:30 AM
Hello
I'm trying to create a bootloader app, which would send parts of intel hex file to the atmega128 we use. I have trimmed the intel hex file and tried to convert it to true hex (as opposed to ascii hex in which intel hex is written). I did so with typecast to string, but noticed that occasionally a stray '0' would be in the output string.
Example:
Instead of 'F1F' it's converted to 'F10F'.
Any ideas as to why this happens? Am i missing half a byte somewhere so it just appends it?
08-05-2022 03:38 AM
It was a line feed character...
08-05-2022 07:23 AM
@AeroSoul wrote:
It was a line feed character...
So where did it come from?
Overall, you code could be greatly simplified because you know the numer of iterations from first principles (i.e. half the string length) so a FOR loop seems more appropriate.
One possible idea from a decades old post here . 😄
08-05-2022 08:26 AM - edited 08-05-2022 08:28 AM
Yep, log 2 ....didn't that change shape?
08-05-2022 11:27 AM
@JÞB wrote:
Yep, log 2 ....didn't that change shape?
Sorry, I don't understand. Is your commend related to any particular part of this thread? Which one?
(I am not using log2 but "Scale by power of two" (AKA: "arithmetic shift", i.e. also scaling negative integers correctly)
08-08-2022 02:32 AM - edited 08-08-2022 02:33 AM
@altenbach wrote:
@AeroSoul wrote:
It was a line feed character...
So where did it come from?
I put it there in previous loop 😄
Also thanks for the simplified code 🙂
08-08-2022 09:28 AM
@AeroSoul wrote:
@altenbach wrote:
@AeroSoul wrote:
It was a line feed character...
So where did it come from?
I put it there in previous loop 😄
Also thanks for the simplified code 🙂
Ah, it's good to know that there is an explanation for the stray linefeed. 😄
Somehow my gut feeling tells me that your "previous loop" code could also be simplified quite a bit, but it's hard to tell from a picture alone. 😉
08-09-2022 02:00 AM
It basically just strips data from the hex file. Removes first 7 characters and last 2, then checks if the first characters from stripped row are '00' (which signifies data row in intel hex) and stores them if it is.
08-09-2022 02:44 AM - edited 08-09-2022 02:47 AM