• AVR Freaks

Hot!Flash Memory Programming - EEPROM Emulation

Author
RonGer
Starting Member
  • Total Posts : 46
  • Reward points : 0
  • Joined: 2018/11/27 08:43:34
  • Location: 0
  • Status: offline
2019/08/27 03:06:34 (permalink)
0

Flash Memory Programming - EEPROM Emulation

Dear all,
 
I'm trying to use the flash memory of the DSPIC33EV256GM104 as a EEPROM.
Therefore I coded a routine, based on the flash_demo project.
For reserving flash memory I'm using the following code line.
uint16_t reserved_flash[1024] __attribute__((space(prog), address(0x1000), section(".reserved_flash"), noload));
 
With this code I would expect that when I reserve memory at address 0x1000, the SW writes to this adress and the next 64 rows. But it doesn't! It writes the data to the address (in hex file) 0x002000.
When I reserve memory at address 0x2000 the SW writes the data to address 0x004000.
The memory should be within the User Flash Memory area (0x000200 - 0x00AB7E).
 
Does anybody know whats the systematic behind this or why this does happen?
 
Kind Regards and thanks in advance
 
Ron
#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 23820
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Flash Memory Programming - EEPROM Emulation 2019/08/27 03:17:46 (permalink)
    0
    Are you allowing for the fact that hex files are byte based?
    All addresses in a hex file refer to byte addresses.
     

    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!
    #2
    RonGer
    Starting Member
    • Total Posts : 46
    • Reward points : 0
    • Joined: 2018/11/27 08:43:34
    • Location: 0
    • Status: offline
    Re: Flash Memory Programming - EEPROM Emulation 2019/08/27 03:33:16 (permalink)
    0
    Hello Ric,
     
    thanks for your fast reply.
    I think I consider that the addresses in a hex file refer to by addresses.
    What I tried to address with e.g. 0x2000 in the hex file, is the line which has this address.
    Unfortunately the data isn't written from this address, but from the address 0x4000 (see hex extract - in fat letters).
    This confuses me.
     
    :103FD000FFFFFF00FFFFFF00FFFFFF00FFFFFF00ED
    :103FE000FFFFFF00FFFFFF00FFFFFF00FFFFFF00DD
    :103FF000FFFFFF00FFFFFF00FFFFFF00FFFFFF00CD
    :104000008810020088100200FFFFFF00FFFFFF0082
    :104010000100000066554400CCBBAA00FFEEDD00A5
    :104020000200000066554400CCBBAA00FFEEDD0094
    :104030000300000066554400CCBBAA00FFEEDD0083
    :104040000400000066554400CCBBAA00FFEEDD0072
    :104050000500000066554400CCBBAA00FFEEDD0061
    :104060000600000066554400CCBBAA00FFEEDD0050
    :104070000700000066554400CCBBAA00FFEEDD003F
    :104080000800000066554400CCBBAA00FFEEDD002E
    :104090000900000066554400CCBBAA00FFEEDD001D
    :1040A0000A00000066554400CCBBAA00FFEEDD000C
    :1040B0000B00000066554400CCBBAA00FFEEDD00FB
    :1040C0000C00000066554400CCBBAA00FFEEDD00EA
    :1040D0000D00000066554400CCBBAA00FFEEDD00D9
    :1040E0000E00000066554400CCBBAA00FFEEDD00C8
    :1040F0000F00000066554400CCBBAA00FFEEDD00B7
    :104100001000000066554400CCBBAA00FFEEDD00A5
    :104110001100000066554400CCBBAA00FFEEDD0094
    :104120001200000066554400CCBBAA00FFEEDD0083
    :104130001300000066554400CCBBAA00FFEEDD0072
    :104140001400000066554400CCBBAA00FFEEDD0061
    :10415000FFFFFF00FFFFFF00FFFFFF00FFFFFF006B
    :10416000FFFFFF00FFFFFF00FFFFFF00FFFFFF005B
    :10417000FFFFFF00FFFFFF00FFFFFF00FFFFFF004B
    :10418000FFFFFF00FFFFFF00FFFFFF00FFFFFF003B
    :10419000FFFFFF00FFFFFF00FFFFFF00FFFFFF002B
    :1041A000FFFFFF00FFFFFF00FFFFFF00FFFFFF001B
    :1041B000FFFFFF00FFFFFF00FFFFFF00FFFFFF000B
    #3
    du00000001
    Just Some Member
    • Total Posts : 3052
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Flash Memory Programming - EEPROM Emulation 2019/08/27 03:50:17 (permalink)
    0
    PEBKAC!
     
    When writing flash on  the dsPICs, the addresses are word addresses. Thus you'd have to divide your byte addresses by 2. This way you'll have 2 bytes for the same address (as the xxx1 is "vanishing" when dividing). IIRC, there may be some more intricacies, but there's some documentation available.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5