PIC16F687 implemented flash size

Discussion in 'Embedded Systems and Microcontrollers' started by noble_soul, Sep 16, 2016.

  1. noble_soul

    Thread Starter New Member

    Feb 10, 2016
    6
    0
    Hi all,

    I am working with the PIC16F687; it's data sheet states that "The PIC has a 13-bit program counter capable of addressing 8Kx14-bit program memory space. ... Only the first 2Kx14 (0000-07FF) are physically implemented for the PIC16F687..."... However I suspect that the chip I am working with actually has a flash size of 4Kx14 (huh...?)

    I generated a hex file with 'garbage data' (i.e. not representing an actual program that can run on the PIC) using Python IntelHex package to fill up 4K of the flash memory (0000-0FFF). The first half (0000-07FF) is filled with 0x2A and the second half (0800-0FFF)is filled with 0x33 (the data values are irrelevant).

    I successfully managed to burn that hex file onto the chip (using MPLABX IDE, IPE and the PK3CMD command line interface), and when reading the PIC memory back, I see that the entire 4K range was correctly written and read back as I specified in the hex file.... How did that happen if the chip only implements 2K of flash?

    I am attaching the hex file that I read back from the chip (this was was read using MPLABX IDE) if anyone wants to inspect it.

    Thanks in advance for any assistance :)
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,154
    1,795
    Did it escape your notice that 2K x 14 bit "words" actually might look like 4K x 8 bit bytes in the hexfile? Actually, in the word, only one of the bytes has a full 8 bits, the other byte has only 6 bits. When the Intel .hex fomat was created (ca. 1970), eveything was byte addressable and there were no partial bytes. Microchip just adapted the defacto standard for their purposes. Using word addressing there are 2K words. Using byte addressing there are 4K bytes and byte fragments.
     
    noble_soul likes this.
  3. noble_soul

    Thread Starter New Member

    Feb 10, 2016
    6
    0
    I see! Thank you for the quick response and the insight. I was too fixated on the numbers and didnt focus on the units... that is my bad.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,154
    1,795
    It's more than OK -- It has happened to most of us at one time or another. I got caught when switching from the 8085 to the 8086. They also had to deal with segmentation. This may or may not be related to 16 byte records which seems to be standard among many compiler writers although it is not part of the written standard.
     
Loading...