Skip to main content
Visitor II
February 16, 2007
Question

Help on In-Application Programming an STR711

  • February 16, 2007
  • 3 replies
  • 889 views
Posted on February 16, 2007 at 05:45

Help on In-Application Programming an STR711

    This topic has been closed for replies.

    3 replies

    Visitor II
    February 13, 2007
    Posted on February 13, 2007 at 10:02

    I'd appreciate some help here, please.

    I have a Front Panel PCB based on an STR711FR0T6 and interfaced

    via USB. I have developed the code with the IAR ARM Kickstart

    Kit version 4.41. Everything has been trouble free until I

    began to add support for in-application reprogramming.

    The entire applcation will be well under 32KB, so the strategy

    is to erase the top 32KB of flash 0, gradually programme the

    top half from USB, then finally erase the bottom half and copy

    the top half to the bottom half. Clearly I can't run the code

    from flash 0 while it's doing any of this, so I have used IAR's

    keyword __ramfunc to locate all the necessary functions (and all

    the functions they call) to RAM.

    The problem is that even an attempt to erase the top 32KB of

    flash 0 stops the device responding over USB until it is power

    cycled.

    I have disabled interrupts at the start of the procedure by a

    call to EIC_IRQConfig (DISABLE), because there are interrupts

    from USB and from the timer (the timer is only used to flash

    LEDs) and clearly the interrupt vectors and handlers are all in

    flash 0. I re-enable interrupts at the end by a call to

    EIC_IRQConfig (ENABLE).

    Can anyone suggest what I've failed to do or done wrong?

    Dave

    Visitor II
    February 14, 2007
    Posted on February 14, 2007 at 06:47

    I'm not using the ST standard software library for the STR71x, so I could be wrong about some things.

    You only need to make a function __ramfunc if it's executed while a flash erase or write operation is in progress. I looked at the source code for the ST standard software library, and I found only two functions that run during sector erase: FLASH_SectorErase() and FLASH_WaitForLastTask(). Those must be __ramfunc. Besides, don't forget about flash module initialization ('STR7 family Flash programming', revision 4, section 2.3.1 'Executing the first Write operation from RAM'), although it shouldn't affect you.

    Try setting some breakpoints with the debugger to see where it goes astray.

    Regards,

    - mike

    Visitor II
    February 16, 2007
    Posted on February 16, 2007 at 05:32

    I found the answer a couple of days ago, but my attempts to reply failed.

    The problem was that I kicked off the erase, then used WaitForLastTask

    to see if it had finished. WaitForLastTask boils down to checking

    FLASH_CR)'s BSY0 bit. Of course, while the erase is going on, the

    BSY bits aren't readable; if you try, the result you get is equivalent

    to not busy! So I returned from the function, to memory that wasn't

    readable. Bang.

    My solution was to use:

    while (FLASHR->FCR0 & (FLASH_LOCK_Mask | FLASH_BSYA1_Mask | FLASH_BSYA2_Mask));

    When I single stepped it under the debugger, there was no problem,

    because I single stepped slowly enough that the erase operation had

    completed.

    Thanks for your help!

    Dave

    [ This message was edited by: DaveHigton on 16-02-2007 10:02 ]