Hello,
I'm having a rather odd problem with FlashLib 1.06. My device is an TMS470M X4MF03107 . I am (for various reasons) obliged to have the watchdog turned on and I am trying to erase a sector in flash bank 0 (the sector at 0x20000, in fact). I'm using EABI, no VFP.
The main body of my code is in sector 0 at 0x00000, and I have copied both my relevant routines and the pf035 flash library (v 1.06) into RAM starting at 0x8000100.
I'm following the instructions in SPNU493C S6.3 and S6.4.
With the watchdog off, everything works just fine - Flash_Erase_B() is a little slow, but it gets there in the end, I can program my flash and checksum it to prove that it's right and all is happy.
With the watchdog on, I get a watchdog reset whilst trying to run Flash_Erase_B(). Compacting the sector works just fine and I am doing that before I try erasing.
A little disassembly gets me to the code:
start = 0x20000
flashCore = FLASH_CORE0
delay = 90 (overkill, since HCLK=80MHz, but setting delay=40 makes no difference)
flashControl = 0xFFF87000
setup_state_machine(start, flashCore, delay, flashControl)
Flash_Start_Command_B(start, flashCore, delay, flashControl, CMND_ERS_SECT, 0xFFFF)
The Flash_Start_Command_B() causes a watchdog reset. If I turn the watchdog off, Flash_Start_Command_B() will return very happily so it isn't that I am going off into the weeds.
A little more investigation (read: overwriting bits of the RAM-resident copy of the library with NOPs) suggests that Flash_Start_Command_B() calls IssueCommand, which calls IssueCommand_U16() twice. The second such call takes a very long while to return, the watchdog gets bored and reboots me.
My question is: what is it that I am doing that has angered the hardware so? And how do I stop doing it? Turning off the watchdog is not an option and neither is leaving this product without an upgrade facility.
I am pretty certain that I am not accidentally accessing Flash whilst trying to program - I've done that before and it leads to an outright hang if the watchdog is off. In this situation, control does eventually return (and the command has succeeded), but too late.