View previous topic :: View next topic |
Author |
Message |
evelikov92
Joined: 10 Mar 2015 Posts: 23
|
How generate hex file |
Posted: Sun Sep 06, 2015 12:04 pm |
|
|
Hi everybody.
Well I have one decimal number, and I want to generate hex file from that number and save in device.
I know how is generate row in hex file
:10 0020 00 E2CF0AF0D9CF0BF0DACF0CF0F3CF14F0 17
10 -> is how bytes is. --> 16 bytes 10 in hex is 16
0020 -> is address
00 -> is for data type
17 -> is checksum
the problem is E2CF0AF0D9CF0BF0DACF0CF0F3CF14F0 this. What is the formula to generate this number.
And how I know how bytes is in the row.
Is there in internet have program for generate one number for hex file.
For me is better way I know the formula. I read how is create but this part (E2CF0AF0D9CF0BF0DACF0CF0F3CF14F0) I dont undarstand.
I hope You undarstand me correct. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Sun Sep 06, 2015 12:19 pm |
|
|
E2CF0AF0D9CF0BF0DACF0CF0F3CF14F0
Is NOT a 'number', rather a series of hex numbers that is the 'machine code' equivalent of a program or a part of it.
This is generated by the compiler to be downloaded into the micro and appears to be 'Intel HEX' format
'0020' is the address but might actually be 2000x not '0020x' though without knowing the origin of the code it's a 50/50 chance.
If you want to KNOW what the code really is...
1) if it's PIC code you need the processor type and get the datasheet
2) look at the 'instruction set' and see which instruction is coded as 'E2'
3) based on that, then decide if 'CF' is data or another instruction...
4) do this for the remaining 14 bytes.
Another way to 'decode' the program is to load it into MPLAB and then look at the 'disassembled' code. This may work though I haven't tried for your 'program'.
Assuming you 'know' what this code does it should take 15-20 minutes to 'decode'.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Sun Sep 06, 2015 12:24 pm |
|
|
A web search for 'Intel Hex' will describe the format you are posting. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 06, 2015 1:12 pm |
|
|
Quote: | I want to generate hex file from that number and save in device. |
Why do you want to save one line of a Hex file in the PIC's flash memory ?
What will your PIC do with that Hex file data ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Sun Sep 06, 2015 4:34 pm |
|
|
too hot to work outside so I chose the 16F877 as the PIC for this program and using the instruction set decoded the 'program'..
took about 1/2 hour.....man I'm rusty !
sure hope it's cooler tomorrow !
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Sun Sep 06, 2015 11:55 pm |
|
|
I think there is a very fundamental misunderstanding going on here.
The idea that the numbers in themselves have a 'magic' significance, with a 'formula' to generate them.
They are just numbers.
Intel Hex, is just a way of transporting these, and putting them in a location.
Their significance only appears in the specific context. Both the location, and the target chip.
The poster needs to understand that a number in the program memory of a chip, is used by the CPU to say what instruction to perform. The same number in a different location can have a completely different meaning (fuses or EEPROM versus program memory, data, or even just located one byte differently, so that the chip reads them in a different order). In a different chip, the numbers will have different meanings. There is no 'formula'. Instead you start with the working out the instruction you want, then go and use the manufacturers tables to look up what 'number' this instruction needs, then possibly add other numbers involved (so a 'jump' will then normally have the address also stored as numbers just afterwards), and the result of this becomes the numbers to go into the hex file. They only work when combined with the other numbers around (so a 'jump' needs code at the location it jumps 'to', etc..).
Fortunately, tools like assemblers, and then compilers, simplify this, doing the conversion to 'numbers' from the instruction listing, or from higher level operations for you.
A single line from a hex file, is like 16 letters taken at random from Shakespeare. Hardly likely to mean anything. |
|
|
evelikov92
Joined: 10 Mar 2015 Posts: 23
|
|
Posted: Tue Sep 15, 2015 10:43 pm |
|
|
I'm sorry for not so much information, and not post again. Thanks for the help for everyone who give me answer.
I need to know how HCS301, generate hex file from manufacture code and other code. How work keeloq algorithm. For me the best way is to know formula for decoder. How program keeloq decoder create hex file from this numbers.
Thanks again. |
|
|
ronaldoklais
Joined: 18 Dec 2012 Posts: 13
|
|
Posted: Wed Sep 16, 2015 7:35 am |
|
|
The hex code of the HCS301 has no relation with the hex code of microchip ICs. Hex is only a way to see or transfer an content with readable form. In ASM, the hex values are bitcodes. In HCS301 the hex has other type of data. |
|
|
|