Connect with us

PIC Hex Files

Discussion in 'Microcontrollers, Programming and IoT' started by Raven Luni, Jul 11, 2013.

Scroll to continue with content
  1. Raven Luni

    Raven Luni

    798
    8
    Oct 15, 2011
    Greetings,

    Just a quick question about the hex file format for PICs. How are the program and data memory separated in the file? There are no clues in any of the datasheets - they only state that both areas start at address 0 - which obviously creates problems if you want both in the same file.

    I'm not particularly keen on the hex file format and have no use for iy myself but I wanted to support it in my assembler so other people can use it.
     
  2. Raven Luni

    Raven Luni

    798
    8
    Oct 15, 2011
    Hmm - might have found something in this forum:
    Now that is bad practice. :p
     
  3. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,497
    2,838
    Jan 21, 2010
    PICs are Harvard architecture. You're thinking von Newmann. That would be the cause of some confusion.
     
  4. Raven Luni

    Raven Luni

    798
    8
    Oct 15, 2011
    Its not the architecture - its the common file format used by the popular programmers and their own tools - the files they like to save the compiled code in before it goes on the chip
     
  5. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    You cannot program the RAM of a PIC in the .HEX file. The EEPROM and program ROM are in the same address space, so no conflict.

    Bob
     
  6. Raven Luni

    Raven Luni

    798
    8
    Oct 15, 2011
    I think youre all missing the point, plus I already got the answer to my question. I'm not talking aobut programming the PIC. I can do that already. I'm not talking about the RAM. I'm talking about the format in which the popular software utilities store the compiled program, which is basically intel's hex format.

    The one I'm using (PIC16F88) has 4K of program memory and 256 bytes of data EEPROM (nothing to do with the RAM) which are both written by the programmer using separate commands. They are also both addressed by the PC starting at address 0, which makes the hex file format inappropriate since each line of a hex file contains an address.

    So, as the guy in the other forum said, they use a convention, which is to place a false address in the hex file to indicate that its a data memory section and not program memory. Apparently this false address is different for each device which makes it a really bad practice. Its an esoteric workaround on their part.
     
  7. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    Are you sure the "false address" is not actually the address of the EEPROM? In a PIC program, you can read and write both program memory and EEPROM with the same instructions, at different addresses. For example, addresses from 0 to 00ffff is program memory and 10000 to 100ff is EEPROM. I will try it out once I get home.

    Bob
     
  8. Raven Luni

    Raven Luni

    798
    8
    Oct 15, 2011
    If youre using a standard programmer with the supplied software then I suspect it will work, because the software is reading the file, then when it comes across that address (or any address above 10000) it sends the load data command and an address of 0 instead of load program.
    That address is also 17 bits long and the PC for this device is 14 bits.
     
    Last edited: Jul 12, 2013
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-