• AVR Freaks

Hot!High endurance flash in PIC16F1716

Author
nandpai
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2015/11/24 10:16:37
  • Location: 0
  • Status: offline
2019/09/12 02:12:09 (permalink)
0

High endurance flash in PIC16F1716

The datasheet for 16F1716 mentions high endurance flash address as 3F80h to 3FFFh. When I write to this address, my program does not work. I find it is used for the program memory. How do I use it for storing data like in a EEPROM and not for program memory.
#1

19 Replies Related Threads

    pcbbc
    Super Member
    • Total Posts : 1332
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 03:09:25 (permalink)
    +1 (1)
    Project Properties -> XC8 Global Options -> XC8 Linker -> Option categories: Memory model, ROM ranges
    post edited by pcbbc - 2019/09/12 03:11:47
    #2
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 03:30:30 (permalink)
    0
    Thanks. But I am not able to figure how to specify the range in the option.
    #3
    crosland
    Super Member
    • Total Posts : 1625
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 03:57:27 (permalink)
    0
    nandpai
    The datasheet for 16F1716 mentions high endurance flash address as 3F80h to 3FFFh. When I write to this address, my program does not work. I find it is used for the program memory. 

    How do you find that? It would ig you explained exactly what you do and what happens.
     
    The HEF is, in very simple terms, part of the program memory but is guaranteed to have higher endurance and may only implement 8 bits at each location.
    #4
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 04:11:37 (permalink)
    0
    I read the memory into a file before and after writing to the HEF.  I found I correctly wrote to the HEF. however, there was some code already written there. 
     
    So I changed my program to write to an area not used by my code and used that to write my data. Unfortunately this was not HEF.
     
     
    #5
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 04:16:05 (permalink)
    0
    I read the memory into a file before and after writing to the HEF.  I found I correctly wrote to the HEF. however, there was some code already written there. 
     
    So I changed my program to write to an area not used by my code and used that to write my data. Unfortunately this was not HEF.
    #6
    pcbbc
    Super Member
    • Total Posts : 1332
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 04:27:54 (permalink)
    +2 (2)
    nandpai
    Thanks. But I am not able to figure how to specify the range in the option.

     
    Look at the help in the Option Description tab...
    Specify ROM ranges
    The compiler initially knows about on-chip ROM only. If external ROM is available then this can be specified via this option. Areas of on-chip ROM that must be reserved can also be listed.
    Examples:
    0-7FF,1000-1FFF ignore on-chip ROM, use only specified ranges;
    default,3000-3FFF use default on-chip ROM, plus an additional range;
    default,-7F0-7FF use default ROM, but reserve 16 bytes at 7F0.

     
    So I'd think you want:
    default,-3F80-3FFF
    #7
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 04:57:40 (permalink)
    0
    I figured out what to do. So when I gave option as default, -1F80-1FFF, the code is not written into this area. However,my data is also not written into the HEF area. Till I figure out what to do, I will continue to write in area which is not HEF, and where the code is not written. Thanks again for the suggestion. I came across an App note 1673 about the same. 
    #8
    pcbbc
    Super Member
    • Total Posts : 1332
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 05:12:21 (permalink)
    +1 (1)
    nandpai
    However,my data is also not written into the HEF area.

    Your application code is writing the data. It cannot possibly be effected by that setting in the linker. It has zero visibility of it.

    The Problem must lie in your code. Are you sure you are erasing the FLASH before writing it?

    Just using some “random” flash area which isn’t currently used by the application now, isn’t any guarantee it won’t suddenly start to get used when you modify your application in the future. So, besides the obvious problem that the area you have chosen is not HEF, it isn’t a very good strategy.

    I suggest you post your code you are using to erase/write values.
    #9
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: High endurance flash in PIC16F1716 2019/09/12 05:24:17 (permalink)
    +1 (1)
    nandpai
    I figured out what to do. So when I gave option as default, -1F80-1FFF, the code is not written into this area. However,my data is also not written into the HEF area.

    Do you mean when your running program tries to write the data there (which cannot be affected by that setting),
    or are you trying to embed initial values for that data into your program?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 17847
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 06:48:11 (permalink)
    +1 (1)
    You can either use the linker settings to stop the compiler from using that area.
    Or you can place a const array there.
    #11
    1and0
    Access is Denied
    • Total Posts : 9771
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 06:52:12 (permalink)
    +2 (2)
    Wouldn't this be easier to reserve the memory space?
    const uint8_t myhef[128] @ 0x1F80;

     
    <edit> Changed 0x3F80 to 0x1F80.
    post edited by 1and0 - 2019/09/14 11:29:54
    #12
    pcbbc
    Super Member
    • Total Posts : 1332
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 07:09:05 (permalink)
    +1 (1)
    Or...
    const uint8_t myhef[128] __at(0x3F80);

    ...if you want to be C99 compliant.
     
    Probably.  But as the OP shares no code, and provides very little explanation of how they are testing or what the results were (other than "it doesn't work"), we have no way of saying.
    #13
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/12 08:00:15 (permalink)
    0
    When m running program tries to write. I am surprised at that too. I will experiment again later.
    #14
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/14 00:24:28 (permalink)
    0
    Hello PCbbc,
     
    I am attaching my complete code to illustrate the problem. I tried to create only the relevant code, but that turned to be difficult. the flash writing and reading code is generated using MCC. 
     
    I have attached two hex files. The memory.hex file is read after programming the IC. The memory_after.hex is after writing data into the HE flash. 
     
    The datasheet specifies 0x3FD0 as the start of the HE FLASH. However, I had to say
    const uint8_t myhef[128] __at(0x1F80);
    and not 0x3FD0.
     
    The flash is written at 0x3F00  when I have specified 0x3FD0. This is not HE FLASH area.
     
    However, what I write and what I read are the same values. 
     
    Thanks for your suggestions. Now I will experiment and figure out how to write in the actual HE FLASH area.
     
     
     
     
     
     
    #15
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: High endurance flash in PIC16F1716 2019/09/14 01:44:49 (permalink)
    +1 (1)
    The datasheet has conflicting information about the memory size.
    Page 2 says PIC16F1713 has 4kW of Flash, and the PIC16F1716 has 8kW.
    Page 17 says PIC16F1713 has 4kW of Flash, last program address is 0xFFF
    and the PIC16F1716 has 16kW, last program address is 0x3FFF
    Page 18 shows the last program address in PIC16F1713 is 0x1FFF
    and last program address in PIC16F1716 is 0x3FFF
     
    Personally, I think page 2 is the only one that doesn't have mistakes.
    The true situation is most likely:
    PIC16F1713. 4kW of FLASH, last address 0xFFF, HEF at F80-FFF
    PIC16F1716. 8kW of FLASH, last address 0x1FFF, HEF at 1F80-1FFF
     
     
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #16
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/14 03:17:02 (permalink)
    0
    Hi Ric,
     
    Thanks for pointing it out.
     
     I changed the HE FLASh address to 0x1F80. The data is still written at the same location as earlier. And it seems to be at byte address 0x03F00, and unfortunately it is not in the HE area. This is bothering me a little bit.
     
    if you do diff of the two hex files in my attached zip file I uploaded earlier, the data i have is clearly visible and the data is correctly written, but at the wrong place. if I did not get any problem trying to write, I will not have noticed this at all. I would have assumed it is written in the HE flash area. 
    #17
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: High endurance flash in PIC16F1716 2019/09/14 03:36:41 (permalink)
    +1 (1)
    Byte address 3F00 is word address 1F80.
    Note that all addresses in the hex file are doubled because hex files only store 8 bits, but program memory is 14 bits.
    I think you ARE writing into the HEF area.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #18
    nandpai
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/11/24 10:16:37
    • Location: 0
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/14 09:55:42 (permalink)
    0
    Thanks for telling me that. I still am not sure. As per the byte address it is starting from 3F00 in my hex file. That will make it non HE flash area.
     
    #19
    1and0
    Access is Denied
    • Total Posts : 9771
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: High endurance flash in PIC16F1716 2019/09/14 11:27:46 (permalink)
    +1 (1)
    nandpai
    Thanks for telling me that. I still am not sure. As per the byte address it is starting from 3F00 in my hex file. That will make it non HE flash area.

    The PIC16F1716 has 8K words of program memory with word addresses 0x0000 - 0x1FFF, and the 128 bytes of HEF are located at 0x1F80 - 0x1FFF.  A program memory word is 14 bits in size and takes two bytes to represent. The hex file is byte addressable; so the byte address in the hex file is double that of the program memory address. That is, divide the byte addresses 0x3F00 - 0x3FFF in the hex file by two and you get word addresses 0x1F80 - 0x1FFF. Got it!?
     
    post edited by 1and0 - 2019/09/14 11:33:17
    #20
    Jump to:
    © 2019 APG vNext Commercial Version 4.5