This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1290NCZAD: Cannot program low flash sector at 120MHz clock speed

Part Number: TM4C1290NCZAD

I am clocking my TM4C1290NCZAD at 120MHz.

My code is split into two sections:  The low flash sector (0-16K) contains a boot-loader program.  The remaining upper sectors contain my main application. 

Using the TivaWare flash routines when running in the low section, I can program the upper flash sectors without any problem.

But using the same TivaWare flash routines running in the upper flash area, the processor resets spontaneously when programming the low flash sector, leaving me with a partially programmed sector.  I can see the data in the flash sector being programmed up to about 0x900, and then it contains the erase value of 0xffffffff for the remainder of the sector.   This is entirely repeatable except that the point when the programming quits varies somewhat.  I have interrupts disabled and the vector table pointing to SRAM during this time.

I have determined that if I lower the system clock frequency to 30MHz during the programming, it seems to work fine.  I restore the original 120MHz after the programming is over.

Any idea why this would happen?

Thanks,

Cliff

  • Maybe you are running into the same issue as in TM4C1294NCPDT: Flash write or erase issue, which has a different work-around of disabling the flash prefetch buffer around flash operations.

  • Hi Chester,

      Thank you for your insights to the problem and suggestion. I hope turning off the prefetch would solve the problem. 

    Hi Clifford,

      As suggest by Chester can you try to disable the prefetch buffer and turn it back on after you finished with the program and erase for improved performance. 

    // Turn off prefetch buffers

    HWREG(0x400FDFC8) = 0x00010000;

    // Turn on prefetch buffers

    HWREG(0x400FDFC8) = 0x00000000;

  • It was a good idea, but it had no effect.

    BTW, to turn on the prefetch buffers: HWREG(0x400FDFC8) = 0x00020000;

    Thanks anyway,

    Cliff

  • Hi Cliff,

      At the moment I cannot make sense why it will work at below 30Mhz but not higher. You said the processor reset spontaneously. Can you please find out what caused the reset event by examining the RESC register? I believe you are using your own custom board, correct? Can you repeat the same problem on the launchPad? Can you repeat the same problem on another custom board? 

  • Hello Charles,

    Thank you for this great suggestion.  I should have checked this register right away.  It led me to the problem and solution.  It all seems so obvious now...

    The RESC bit set was WDT0, watchdog timer reset.  I have the watchdog timer enabled and re-triggered by a timer-driven interrupt routine.  During the flash erase-program step, I locked out interrupts.  Since this device has 16Kb sectors, the operation takes too long and the watchdog times out.  The solution was easy:  don't lock out the interrupts.

    The reason slowing down the system clock let it work was because I did not update the watchdog registers based on the new clock rate.  So the watchdog interval was effectively increased by a factor of 4.

    The reason my boot-loader did not have this problem is because it does not enable the watchdog timer.  It has nothing to do with the flash sector address.

    Thank you for your advice.  Now I can relax a little.  Have a great weekend.

    Best regards,

    Cliff