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.

EK-TM4C1294XL: How to reprogram a Launchpad with bad/crashing firmware loaded

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: LMFLASHPROGRAMMER, , TM4C1294NCPDT, TPS2052B

I am in the process of debugging some PWM code, see here -

I added the code below to the PWM code above, as the last line of code -

/************************************************************************************************************************************/
/**	@fcn		void divsclk_init(void)
 *
 *  @section	Source
 *  			e2e.ti.com/.../1249830
 *
 *  @section	Current Result
 *  			PQ4 toggles at T=6.235us for 174us, then the system hangs and PQ4/PF2/PF3 stop
 *  			This occurrence repeats at a period of about 21ms
 *
 *  			T=6.235us, N=100
 *  			Tclk = 6.235/100 -> 62.35ns
 *  			Fclk = 16MHz
 *
 *  			I observe this to mean I have the wrong clock selected as the internal 16 MHz oscillator?
 */
/************************************************************************************************************************************/
void divsclk_init(void) {

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
	GPIOPadConfigSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);

	GPIOPinConfigure(GPIO_PQ4_DIVSCLK);

	GPIODirModeSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_DIR_MODE_HW);

	SysCtlClockOutConfig(SYSCTL_CLKOUT_EN | SYSCTL_CLKOUT_SYSCLK, 100);		/* Divide by 100										*/

	return;
}

Now my Launchpad hangs, and both Code Composer and LM Flash both cannot access the Launchpad!

  • CCS Report: "Error connecting to the target. Frequency is out of range"
  • LM Flash Report: "**ERROR**: Unable to find a target!

 

Questions

  • How can I correct this, and resume debugging and programming of my Launchpad??
  • Errr, what the heck is occuring here? What did I do to cause this and how can I correct it, while still outputting DIVSCLK to PQ4?

Didn't expect that one, sheesh! :(

  • Hello Justin

    Please refer to the unlock sequence as given in the application report

    www.ti.com/.../spma075.pdf

    I don't see any reason why the same would occur. I have used the PQ4 pin as clock pin for a camera and never seen an issue like the same.
  • Justin Reina89 said:
    Didn't expect that one, sheesh! :(

    And - who is to blame for your (limited) expectations?   Failures occur w/regularity - solution-searching (as opposed to complaining) proves superior.

    JTAG pins AND System Clock are notorious here for, "Locking users out!"   (some vendors provide special (lost) "boot pins" to simplify recovery)

    Recall that you reported (yet another thread) a mismatch between your System Clock and scope's measure.   And one here (moi) suggested that you, "Provide your System Clock and PWM code - impacted by System Clock.   It would have proved safer to present that code for "free & fast" review - prior to actually implementing and running it.

    We "feel your pain" yet suggest your expectations be adjusted to (better) reflect "MCU field" reality.   System's crash w/regularity - this "comes w/the gig" - your management of the recovery (beyond complaint) is crucial...

  • Amit, thank you!

    I used the following to correct this:

    For convenience for future readers, here is the procedure from Sec 5.3.1 (direct copy):

    • Start the LMFlashProgrammer utility and go to the tab “Other Utilities”
    • Select the radio button in front of “Fury, DustDevil, TM4C123 and TM4C129 Classes”

    • Power down the board containing the locked microcontroller
    • Power up the board, while holding down the reset. The reset must remain pressed unless instructed by the LMFlashProgrammer to be released
    • Press the “Unlock” button in LMFlashProgrammer. Press “Yes” in the pop up message box and then press “OK” in the information message box
    • After some time, a pop up Information box will ask to release the reset. Release the reset and press OK in LMFlashProgrammer utility
    • Finally, the board must be power cycled. At the end of this step, the TM4C12x microcontroller should return to its factory state

    Thank you immensely for helping guide me towards solution. In retrospect perhaps, I should have known to look here but did not.


    Thank you!! :)!

  • Hello Justin,

    But it still does not explain why setting PQ4 causes the issue of lock up in the first place.
  • I am actually working on debugging then resolving this right now. I will post the answer here on completion.
  • The following code produces the same error state (truncated form of OP):

    int main(void) {
    
    	SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_OSC), 25000000);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
    
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOQ));
    
        GPIOPinConfigure(GPIO_PQ4_DIVSCLK);
    
        GPIOPadConfigSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);
    
        GPIODirModeSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_DIR_MODE_HW);
    
        SysCtlClockOutConfig(SYSCTL_CLKOUT_EN | SYSCTL_CLKOUT_SYSCLK, 100);
    
    	for(;;);
    }

    When debug stepping through this code in CCS the code hangs at SysCtlClockOutConfig(), reporting the following info to the Console:

    CORTEX_M4_0: Can't Run Target CPU: Timed out while waiting for target powerup/polling a hardware resource.
    CORTEX_M4_0: Error: Connection with the target was unexpectedly lost.
    CORTEX_M4_0: Failed to remove the debug state from the target before disconnecting.  There may still be breakpoint op-codes embedded in program memory.  It is recommended that you reset the emulator before you connect and reload your program before you continue debugging

    Thoughts?

    Note: I tried GPIOPinTypeDIVSCLK(GPIO_PORTQ_BASE, GPIO_PIN_4); before the SysCtlClockOutConfig call and it did not solve the problem. Thought I would just desperately try ;0...

  • Hello Justin

    Which TivaWare version are you using? I can perhaps try this on my EK-TM4C1294Xl and share the results tomorrow,
  • I am using TivaWare_C_Series-2.1.3.156.
  • Justin Reina89 said:

    The following code produces the same error state (truncated form of OP):

    On the EK-TM4C1294XL Pin PQ4 of the TM4C1294NCPDT is connected to U4 pin 5. The referenced thread contains the comment:

    You must also cut trace from U4 pin 5 if you use a EK_TM4C1294XL eval board or you will get suddenly a message that the JTAG debugger could not connect.

    Perhaps U4 pin 5, which is an open collector output on U4 TPS2052B Power-Distribution Switch, is shorting the TM4C1294NCPDT  DIVSCLK output on pin PQ4?

  • Oh my, cutting the U4.5 trace immediately corrected the problem. See below for the cut made -

       

    A bit embarrassing that I missed such an obvious config and debug step, my strong apologies. Thank you for the help!!

    Status

    • Code outputs SysClk to PQ4
    • Code runs through and does not hang, maintaining JTAG connection

    Thank you again!