Author Topic: Intel Hex format and PIC 12F675  (Read 4467 times)

0 Members and 1 Guest are viewing this topic.

Offline pyroespTopic starter

  • Regular Contributor
  • *
  • Posts: 180
  • Country: be
    • Nicolas Electronics
Intel Hex format and PIC 12F675
« on: July 03, 2012, 12:29:53 am »
Hey everyone,

I couldn't find a free MPASM decompiler so I thought, why not make one ?
So I've just started yesterday. My ihex parser is done, it doesn't take everything into account, like the address of the first byte on a line or any other record type than 00, but it returns a pointer to an array filled with 'raw' data.

(Note : I probably should add the address of each byte, maybe I'll do it after I'm done with this post)

I'm using a program (written in MPASM) I recently made and I've just noticed something and I don't know why it's there.
Take a look at the 2nd line of the end of my hex file:
Quote
:0A0140002F202F202F20850108003A
:02400E00B43FBD
:00000001FF

That line tells me that the value 0x3FB4 will be written at address 0x400E in the microcontroller.
But the program memory map of the 12F675 only goes to 0x1FFF.
Also, 0x3FB4 can be translated to:
Quote
0011 1111 1011 0100 = 0x3FB4
From instruction set mid-range MCU:
0011 111x kkkk kkkk = ADDLW k
Thus:
ADDLW    0xB4

Why would there be an ADDLW 0xB4 at address 0x400E ?
(Note : I never used ADDLW in my program)

The record type on that line is '00' so it's getting written in the data array as well.

Any thoughts on this ?

pyroesp
« Last Edit: July 03, 2012, 12:58:56 am by pyroesp »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: Intel Hex format and PIC 12F675
« Reply #1 on: July 03, 2012, 12:47:36 am »
Could it be EEPROM?

I dunno about PICs but with AVRs you can set it to increment an EEPROM address every time you flash your device.
Does the value change at all?
« Last Edit: July 03, 2012, 12:49:13 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline pyroespTopic starter

  • Regular Contributor
  • *
  • Posts: 180
  • Country: be
    • Nicolas Electronics
Re: Intel Hex format and PIC 12F675
« Reply #2 on: July 03, 2012, 12:52:17 am »
I didn't do anything to write in the EEPROM and I think if there's something to flash to the EEPROM it will be written in another hex file (name.eep.hex or something like that).

I have cleaned and build the project again and the value doesn't change.

pyroesp

EDIT:
Just checked if this was the CONFIG bits address, but no, these are at 0x2007.
« Last Edit: July 03, 2012, 01:01:13 am by pyroesp »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: Intel Hex format and PIC 12F675
« Reply #3 on: July 03, 2012, 12:59:49 am »
Maybe it's just packing it out with random data to get a specific length?
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline pyroespTopic starter

  • Regular Contributor
  • *
  • Posts: 180
  • Country: be
    • Nicolas Electronics
Re: Intel Hex format and PIC 12F675
« Reply #4 on: July 03, 2012, 01:14:19 am »
I should have searched before asking, sorry.
It seems to be the config bits (stupid me, how else could they be written ?).
This is what I found, but if someone can explain this to me, because I don't understand it.

Quote
Data record
Example of a data record with configuration memory of a 14-bit part.:02400E00413F30

• Length of the record:
02
- Size of the configuration memory is one word = 14 bits = 2 bytes (aligned to whole bytes)

• Record address:
400E
- Address of the configuration memory is 2007h which, addressed by bytes, is 400Eh

• Record type:
00
- Data record

• Record data:
413F
- Configuration word is 3F41h

• Checksum:
30
= 02 + 40 + 0E + 00 + 41 + 3F = xxD0; neg D0 =

EDIT:
Nevermind, I found it. 0x2007 = (0x400E / 2).

I suppose this is the config address of all mid-range MCUs ?
How else can the decompiler tell if it's an MPASM instruction or CONFIG word, right ?
« Last Edit: July 03, 2012, 01:23:26 am by pyroesp »
 

Offline pyroespTopic starter

  • Regular Contributor
  • *
  • Posts: 180
  • Country: be
    • Nicolas Electronics
Re: Intel Hex format and PIC 12F675
« Reply #5 on: July 03, 2012, 03:27:16 pm »
I'll answer my own question
0x2007 is the CONFIG address of all 14 bit core PIC MCU, see chapter 27.1 : http://ww1.microchip.com/downloads/en/devicedoc/33023a.pdf

pyroesp
« Last Edit: July 03, 2012, 06:25:12 pm by pyroesp »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf