• AVR Freaks

DEE Emulation during developing

Author
Kopka
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2007/11/07 01:39:03
  • Location: Germany
  • Status: offline
2009/07/18 09:54:48 (permalink)
0

DEE Emulation during developing

Hi Everybody,

I use the DEE Emulation 16-bit program (ApplNote AN1095) on a PIC24FJ256GB106.
It works fine without any fail.

But a new devcice programming overwrite the values. This is quite normal - but onerous during developing.

I use PicKit III on MLAB IDE v8.33 with C30.

During programming with PicKit 3 is possible to preserve program memory.

Now my problem :

I have no idea to change the memory area inside the DEE Emulation program. Also no idea to find out where the used memory area is.


Any idea to help me with this problem? Thanks lot for your help!

Michael 
#1

13 Replies Related Threads

    MBedder
    Circuit breaker
    • Total Posts : 6779
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    RE: DEE Emulation during developing 2009/07/18 11:26:56 (permalink)
    0
    Memory preservation can be configured in the MPLAB Programmer-Settings dialog pane
    #2
    Kopka
    Starting Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2007/11/07 01:39:03
    • Location: Germany
    • Status: offline
    RE: DEE Emulation during developing 2009/07/19 03:29:20 (permalink)
    0
    Yes - I know. But I do'nt know the adresses that the emulation use. And I see no way to change / fix this memory range.
    #3
    pichacker
    Starting Member
    • Total Posts : 44
    • Reward points : 0
    • Joined: 2007/02/21 13:58:37
    • Location: 0
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 01:49:25 (permalink)
    0
    I asked this a while ago and no one was able to help. In the end I set up a function to write suitable default values to "EEprom" emulated memory. Not too good if your data keeps changing between each compile but better than nothing.
    #4
    sequoia
    Super Member
    • Total Posts : 222
    • Reward points : 0
    • Joined: 2008/08/04 17:17:09
    • Location: 0
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 06:06:21 (permalink)
    0
    I believe the eedata section address is specified in the gld linker file. Look there and at the linker documentation. If you don’t find what you need, you could possibly write a relatively unique bit pattern to the EE memory then search it out with the PICKIT. That should tell you the address. But remember if the address isn’t fixed, the linker may well move it with each build.
    post edited by sequoia - 2009/07/21 06:14:15
    #5
    nice
    Super Member
    • Total Posts : 1088
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 12:56:14 (permalink)
    0
    But remember if the address isn’t fixed, the linker may well move it with each build.

    The address isn't fixed.

    unsigned char emulationPages[DATA_EE_BANKS * NUM_DATA_EE_PAGES][NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2]
                                __attribute__ ((space(psv), aligned(NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2), noload));

    By adding the address attribute (and taking care of the required alignment by yourself) the code can easily be modified to use a fixed address.

    There's also a potential hazard in the code given in the AN1095. If the linker decides to use the very last program memory page for EEPROM emulation, the code will sooner or later wipe out the configuration bits. I don't know whether the C30 toolchain prevents 'psv' from being allocated to the very last memory page or not. If it does, everything is ok. Otherwise it's a bug just waiting to bite someone.

    Best regards,
    Bernd

    #6
    Neiwiertz
    Super Member
    • Total Posts : 2094
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 13:59:47 (permalink)
    0
    Good catch about the possible wipe out Bernd (can you report this one to support)

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #7
    nice
    Super Member
    • Total Posts : 1088
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 14:16:24 (permalink)
    0
    (can you report this one to support)

    I'll do so tomorrow. It's getting late here in Germany...

    Best regards,
    Bernd
    #8
    aschen0866
    Super Member
    • Total Posts : 4494
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 15:03:28 (permalink)
    0
    It is not really a bug because NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2 in the emulationPages[][] definition would force the array to take up the entire Flash page, at least one. Therefore if the array ever gets to the last Flash page where configuration words reside, the link would fail. Try this test code

    #include <p24FJ256GA110.h>

    #define NUMBER_OF_INSTRUCTIONS_IN_PAGE 512

    _CONFIG1(JTAGEN_OFF /* JTAG Diabled */
    & GCP_ON /* Code Protection Enabled */
    & GWRP_OFF /* Write Protection Disabled */
    & BKBUG_OFF /* Background Debugger Disabled */
    & COE_OFF /* Clip-on Emulation Mode Disabled */
    & ICS_PGx1 /* ICD Pins Select: EMUC/EMUD share PGC1/PGD1 */
    & FWDTEN_OFF /* Watchdog Timer Disabled */
    & WINDIS_OFF); /* Windowed WDT Disabled */

    _CONFIG2(IESO_OFF
    & FNOSC_PRI /* Primary oscillator (XT, HS, EC) */
    & FCKSM_CSECMD /* Clock switching enabled */
    & OSCIOFNC_OFF /* OSCO/RC15 function: OSCO or Fosc/2 */
    & IOL1WAY_OFF /* Unlimited Writes To RP Registers */
    & POSCMOD_XT); /* XT Oscillator */

    _CONFIG3(WPEND_WPSTARTMEM /* Write Protect from page 0 to WPFP */
    & WPCFG_WPCFGDIS /* Write Protect Configuration Page Disabled */
    & WPDIS_WPDIS); /* Write Protection Disable */

    unsigned char emulationPages[NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2]
    __attribute__ ((space(prog), address(0x2A800))); /* 0x2A800 is the beginning of the last Flash page */

    int main( void )
    {

    while (1);

    return (0);
    }


    Build fails:

    c:\program files\microchip\mplab c30\bin\bin\pic30-coff-ld.exe: Link Error: region config3 is full (out\Test30.cof section __CONFIG3)
    c:\program files\microchip\mplab c30\bin\bin\pic30-coff-ld.exe: Link Error: region config2 is full (out\Test30.cof section __CONFIG2)
    c:\program files\microchip\mplab c30\bin\bin\pic30-coff-ld.exe: Link Error: region config1 is full (out\Test30.cof section __CONFIG1)
    c:\program files\microchip\mplab c30\bin\bin\pic30-coff-ld.exe: Warning: absolute section '_01778e004a6639c7' crosses the boundary of region program.
    Link Error: Could not allocate section _01778e004a6639c7 at 0x2a800
    Link Error: Could not allocate program memory
    Link step failed.




    #9
    nice
    Super Member
    • Total Posts : 1088
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 15:39:18 (permalink)
    0
    Therefore if the array ever gets to the last Flash page where configuration words reside, the link would fail.

    Thanks for the input, it saves me some tests I planned for tomorrow before submitting the ticket. Would the link stage also fail, if no configuration words are present in the code? Of course this is considered bad practice when creating a stand alone hex file, but it's a rather common approach when using a bootloader (where it doesn't make much sense to touch the configuration words at all, since changing them may negatively affect the bootloader).

    Best regards,
    Bernd

    #10
    aschen0866
    Super Member
    • Total Posts : 4494
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    RE: DEE Emulation during developing 2009/07/21 16:23:55 (permalink)
    0
    ...where it doesn't make much sense to touch the configuration words at all, since changing them may negatively affect the bootloader

    Can't agree with you more - The last Flash page should be excluded from the application's program region.
    #11
    nice
    Super Member
    • Total Posts : 1088
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    RE: DEE Emulation during developing 2009/07/22 01:59:45 (permalink)
    0
    Would the link stage also fail, if no configuration words are present in the code?

    To answer my own question: It fails.

    c:\programme\microchip\mplab c30 v3.12\bin\bin\pic30-elf-ld.exe: Warning: absolute section '_018e5a104a66b7e6' crosses the boundary of region program.
    Link Error: Could not allocate program memory.
    Link step failed.


    It is not really a bug

    Agreed.

    Best regards,
    Bernd
    #12
    Neiwiertz
    Super Member
    • Total Posts : 2094
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: DEE Emulation during developing 2009/07/22 10:23:27 (permalink)
    0
    Thanks for the heads up the linker will kick-in and explain.

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #13
    nice
    Super Member
    • Total Posts : 1088
    • Reward points : 0
    • Joined: 2004/09/18 11:42:25
    • Location: Germany
    • Status: offline
    RE: DEE Emulation during developing 2009/07/22 14:07:43 (permalink)
    0
    As I said, it was 'too late in the evening' to submit a support ticket. I've simply missed the fact aschen0866 pointed out, that the linker doesn't allow to allocate the whole last program memory page (the last bytes are reserved for the configuration words by the gld file) [8|].

    Best regards,
    Bernd
    post edited by nice - 2009/07/22 14:10:46
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5