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.

TM4C129ENCPDT: Custom board fails to debug when switch from internal oscillator to 25 MHz crystal.

Part Number: TM4C129ENCPDT

Hello all,

I'm using TivaWare_C_Series-2.1.0.12573, with CCS6.1.0. My code is just a simple blinky code I have writen for the custom board:

#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c1294ncpdt.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "../../../UnitestLibraries/unitest_tm4c1294ncpdt_peripherals.h"
#include "../../../UnitestLibraries/unitest_tm4c1294ncpdt_gpio_init.h"
#include "../../../UnitestLibraries/unitest_tm4c1294ncpdt_timer_init.h"
#include "../../../UnitestLibraries/unitest_tm4c1294ncpdt_timer_func.h"

void Timer0IntHandler(void);

uint32_t timerVal;


int main(void)
{

	uint32_t ui32SysClkFreq;

	ui32SysClkFreq = SysCtlClockFreqSet(SYSCTL_OSC_INT | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_320, 40000000);
	//ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
	//SYSCTL_OSC_INT

	initGPIOKOutput(GPIO_PIN_0|GPIO_PIN_1, 0x00);
	init32BitTIMERPeriodicMode(SYSCTL_PERIPH_TIMER0, TIMER0_BASE, time2TimerLoadbySysClk(ui32SysClkFreq, 0.5, 0)); // 2ms
	interruptInitTIMER(INT_TIMER0A, TIMER0_BASE, TIMER_A, TIMER_TIMA_TIMEOUT, Timer0IntHandler);

	IntMasterEnable();
	MAP_TimerEnable(TIMER0_BASE, TIMER_A);

	while(1);
}

void Timer0IntHandler(void)
{
	// Clear the timer interrupt
	TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

	// Read the current state of the GPIO pin and
	// write back the opposite state
	if(GPIOPinRead(GPIO_PORTK_BASE, GPIO_PIN_0))
	{
		GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_0|GPIO_PIN_1, 0);
	}
	else
	{
		GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_0|GPIO_PIN_1, 1);
	}
}

The issue is that when I am using the internal oscillator I can embed the code and no problem appears. But when I switch the code from internal oscillator to 25 MHz crystal, I can embed the code but the MCU gets locked. I have to go through an erase procedure to contect to the chip. I am using the recomended crystals (which is exactly the same as the crystal used in the Tiva connected board.) and I also have the RBIAS resistor connected.

I haven't been able to find the source of the error, and would be happy if someone could help out. 

  • You may be running into an issue referred to as SYSCTL#22. It is described in the errata document www.ti.com/lit/spmz850. The solution is to update to the latest TivaWare drivers. Here is a snapshot of the erratum:

  • Thank you Bob,

    I have missed this. I'll check and inform you if it works out.
  • Hello Bob,

    I have updated my TivaWare to the most recent one and nope still does the same thing. I have 5 copies of the same board all have the same problem. Here is what happens:

    1. The code works fine with intrenal oscillator, so I switch the code to 25 MHz crystal, 

      

    The code loads with no problem.

    2. When I press the resume button to see the blinking:

    I get the: "Can't run Target CPU: Debug port error occurred." 

    I don't believe there is something wrong with the JTAG port otherwise it wouldn't load the the previous code. Everything works fine with internal oscillator, but when I switch to crystal it blows.

    3. Also when I do  debug port unlock procedure, something weird happens. When I reach the final step, which is to re-power the device, and load the working code I again get the same error. But if I don't disconnect  the power cable (meaning I am not completeing the power cycle) And the compile the code it gives me a warning that the device couldn't be reached, then I disconnect and connect the device anr retry compile and it works.

    I am a bit lost on whats going on and open to advices...

  • Murat Bilgic said:
    I don't believe there is something wrong with the JTAG port otherwise it wouldn't load the the previous code. Everything works fine with internal oscillator, but when I switch to crystal it blows.

    The code to switch to the 25MHz crystal looks correct.

    Are you able to try running the code on a launchpad?

    If the code runs OK on a launchpad, it points at maybe a fault on the custom boards with the 25MHz crystal circuit.

  • Chester has raised a good point [LIKE]. Have you looked at the 25MHz crystal with a scope to see that it is oscillating properly?
  • Beyond probing - it proves always wise to build boards in multiple. Such would provide indication if you've suffered, "Single board anomaly" (bane of all diagnostics).

    At 25MHz - your quality of scope probe may impede your measurement. I'd suggest a far lower frequency crystal - close to the "minimum frequency acceptable" by your MCU. Crystal bypass caps play a key role too - mis-marked caps (too high in value) or missing - surely could cause your issue.
  • Murat Bilgic said:
    The code loads with no problem.

    2. When I press the resume button to see the blinking:

    Murat Bilgic said:
    I get the: "Can't run Target CPU: Debug port error occurred." 

    Correct me if wrong but would not that indicate the MOSC is clocking Flash memory and AHB bus. Secondly even with ICDI setting checked to reset target, run to main after a program load (CCS5.4 & 7) often have to click on reset target and restart before clicking on resume or the DAC throws CCS an exception of connection error.