TM4C123GH6PM: Can not enter timer0A ISR

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL, EK-TM4C1294XL, TM4C123GH6PZ

Tool/software:

Hi all,

Our company has used MSP432P401R chip as our 32-bit embedded controller for several products.

After MSP432P401 stop supporting, we are now trying to use TM4C series chip as our main 32-bit MCU.

We bought the TM4C123G LaunchPad.

I am trying to transfer the code to TM4C chip for our next product.

When I was checking the function of Timer, I can not enter ISR.

The system stuck in static void IntDefaultHandler(void) of tm4c123gh6pm_startup_ccs.c.

These are the code below.

Are there any problems in the code? Or how can I solve the problem?

BTW, I used register level to code MSP430 and MSP432 previous, so this is the first time using the method to code TI chips.

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/gpio.h"

void Delay(unsigned long time);
void Initialize(void);
void Set_Timer(void);

unsigned short breathe;

void main(void)
{
	// Set the clocking to run directly from the crystal.
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

	Initialize();
	while(1)
	{
	}
}

void Initialize(void)
{
	//***********************
	//* variables and flags *
	//***********************
	breathe=0;
	//*******
	//* I/O *
	//*******
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);// Enable the GPIO port that is used for the on-board LED.
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);// Enable the GPIO pins for the LED (PF1 & PF2 & PF3).

	//*************
	//* Operation *
	//*************
	Set_Timer();
}

void Set_Timer(void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);// Enable the peripherals used by this example.
	IntMasterEnable();// Enable processor interrupts.

	// Configure the two 32-bit periodic timers.
	TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
	TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet());

	// Setup the interrupts for the timer timeouts.
	IntEnable(INT_TIMER0A);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

	TimerEnable(TIMER0_BASE, TIMER_A);// Enable the timers.
}

#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void Timer0IntHandler(void)
{
	TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);// Clear the timer interrupt.
	if(breathe)
	{
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0x04);
		breathe=0;
	}
	else
	{
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, ~0x04);
		breathe=1;
	}
}

  • The system stuck in static void IntDefaultHandler(void) of tm4c123gh6pm_startup_ccs.c.

    Hi Norton,

      Can you show your startup_ccs.c code? You need to make sure you have a vector declared for Timer_A in the vector table. By default, the startup file is filled with IntDefaultHandler for all vectors. See below example. Please also make sure you use the startup_ccs.c file for TM4C123 and not copy the any starrtup file from MSP432P as they are not compatible.

     

  • Hi Charles,

    Thanks for the replying.

    Where can I find the startup_ccs.c file the the TM4C123?

    There is only tm4c123gh6pm_startup_ccs.c file in the created project.

    I have showed my tm4c123gh6pm_startup_ccs.c and there are not any IntHandler in the file but lots of InfDefaultHandler.

    Should I need to edit the Handler by myself?

    It seems that I can not just change the "InfDefaultHandler" to the function of my ISR.

    Sure I do not copy any file from MSP432P.

    I created a new project for the TM4C123 and and linked TivaWare_C_Series-2.2.0.295.

  • I have showed my tm4c123gh6pm_startup_ccs.c and there are not any IntHandler in the file but lots of InfDefaultHandler.

    Should I need to edit the Handler by myself?

    It seems that I can not just change the "InfDefaultHandler" to the function of my ISR.

    Sure I do not copy any file from MSP432P.

    I created a new project for the TM4C123 and and linked TivaWare_C_Series-2.2.0.295.

    How did you create the project? I don't think you created the project by importing an existing project from the TivaWare SDK. There is already a timer project that exactly demonstrates what you want to accomplish. Please do as follows. 

    1. Import the timers project from C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\timers. Please note it is to import, NOT copy the project. The TivaWare examples are prebuild and are ready to run out of box. All you need to is to import them into the CCS workspace. To import a project in CCS, go to File->Import and project the path to C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\timers. 

    2. Run the timers example project. You should see LED blinking on the LaunchPad after the timer expires. There are two timers configured and they are TIMER0_A and TIMER1_A in this example. 

    3. Look at the startup_ccs.c file. All TivaWare examples have the startup_ccs.c file, not tm4c123gh6pm_startup_ccs.c. You might have imported some examples from the Resource Explorer. Is that correct.

    4. In any case, always start with a working example from the SDK as all examples in the SDK have the correct CCS build settings and necessary files (startup file, cmd file and etc) to build the project. 

  • Hi Charles,

    Thanks for the replying.

    I have tried to import the exist import from the TivaWare SDK again.

    The project can work now.

    The steps are the same as previous but I have no idea why it could not work in the previous project.

    Sure I do not use copy to create a new project.

    These are still some questions that I want to check.

    1. We used to create a brand new project while using MSP430 and MSP432 series.

    Now I use import operation for new project.

    Once I use the import operation for the new project, the imported project would copy to workspace path.

    I can code and change the *.c file and it would not make any influences to the example project.

    Is that right?

    2.We need to manage the projects of every products.

    How can I change the name of the import project?

    3.I have checked the startup_ccd.c file.

    The Handlers for use are Timer0IntHandler and Timer1IntHandler.

    What should I do if need to use other interrupt function?

    It usually needs several interrupt functions, like UART, Timer, I2C, ADC, etc.

    4.For the sample timers project, it need Timer0IntHandler and Timer1IntHandler.

    If there is only void Timer0IntHandler(void) in the timers.c file, it could not work.

    I have tried to change the code into my code which is showed in the original post.

    The problem shows the error, unresolved symbol Timer1IntHandler, first referenced in ./startup_ccs.obj.

    I also tried to add a function, void Timer1IntHandler(void), with empty { }, and it can work.

    It actually make no sense for me or for the coding but maybe for compiler.

    How can I solve the problem?

    5.Can I use the same sample project for other TIVA series chip?

    Sure the Pin definition should be changed.

    If the problems are solved, I will make a new PCB layout with other TM4C123 chip.

    This is for the new product of our company.

    Actually, it will be the upgrade version of the exist product because MSP432P401R has been stopped supplying.

    It use lots of I/Os on that PCB, so the chip on the launchpad is not enough for the same product.

    6.I used register level for coding in MSP430 and MSP432 series chips.

    Are there any register level sample code for TIVA, or I can only use API method for TIVA coding?

  • Hi Norton,

    1. We used to create a brand new project while using MSP430 and MSP432 series.

    Now I use import operation for new project.

    Once I use the import operation for the new project, the imported project would copy to workspace path.

    I can code and change the *.c file and it would not make any influences to the example project.

    Is that right?

    Correct. During import, if you select "Copy projects into workspace' then it will not have influence to the example projects installed under C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl. 

    2.We need to manage the projects of every products.

    How can I change the name of the import project?

    Just right-click the project and rename it to any name you like. 

    3.I have checked the startup_ccd.c file.

    The Handlers for use are Timer0IntHandler and Timer1IntHandler.

    What should I do if need to use other interrupt function?

    It usually needs several interrupt functions, like UART, Timer, I2C, ADC, etc.

    You just plug in the ISR vectors for the peripherals you want. Let's take UART0RX for example. You would add and vector that points to the ISR for UART. See below example. Whenever the UART0 receives data, it will generate an interrupt and the processor will jump to UARTIntHandler to process the interrupt. 

    4.For the sample timers project, it need Timer0IntHandler and Timer1IntHandler.

    If there is only void Timer0IntHandler(void) in the timers.c file, it could not work.

    I have tried to change the code into my code which is showed in the original post.

    The problem shows the error, unresolved symbol Timer1IntHandler, first referenced in ./startup_ccs.obj.

    I also tried to add a function, void Timer1IntHandler(void), with empty { }, and it can work.

    It actually make no sense for me or for the coding but maybe for compiler.

    How can I solve the problem?

    If you don't need the Timer1_A then you need to first disable this timer so it will not generate an interrupt in the first place. In the startup_ccs.c file you simply just replace Timer1IntHandler with IntDefaultHandler. 

    5.Can I use the same sample project for other TIVA series chip?

    Sure the Pin definition should be changed.

    If the problems are solved, I will make a new PCB layout with other TM4C123 chip.

    This is for the new product of our company.

    Actually, it will be the upgrade version of the exist product because MSP432P401R has been stopped supplying.

    It use lots of I/Os on that PCB, so the chip on the launchpad is not enough for the same product.

    Which Tiva chip are you talking about? You can reuse the example project for TM4C123 chips without much change. The only change that you might need is due to different packages where the pinmuxing code need to be modified. There is no need to change anything for the Timer module. It is only the pinumxing code to change from one package to another. For example if you have a TM4C123GH6PM (64pin), the pin muxing would be different compared to TMP4C123GH6PZ (100pin). 

    6.I used register level for coding in MSP430 and MSP432 series chips.

    Are there any register level sample code for TIVA, or I can only use API method for TIVA coding?

    Register level coding is not recommended for Tiva.  TheTivaWare SDK has the peripheral drives that will extremely save you the development time. The SDK is proven. Writing in register level is extremely error prone. Refer to the his FAQ #4. 

     https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/695568/faq-faqs-for-tm4c-arm-cortex-m4f-microcontrollers 

  • Hi Charles,

    Thanks for the reply.

    All the questions are solved except 5.

    It is so cool that you replied the chip we decided.

    The previous 32-bit MCU of the product is MSP432P401R which is 100pins MCU.

    Almost all the pins are defined on the PCB, so the chip TM4C123GH6PZ would be selected.

    How can I change the pinmuxing code?

    Can I just right click on the project, select properties->CCS General, and select the chip on the list, Variant?

    If not, please let me know how I can do to change the pinmuxing code for the other MCU.

    On the other hand, if the operations for setting chip is correct, the pinmuxing code will be replaced into the same chip as the properties, right?

    BTW,

    I have discussed to my boss about these issues.

    He agreed to designed new PCB with this Tiva chip, TM4C123GH6PZ, for the upgrade to the product.

  • Hi Norton,

      Please see below. Please change from PART_TM4C123GH6PM which comes with the TivaWare SDK to PART_TM4C123GH6PZ. TivaWare SDK has PART_TM4C123GH6PM because the TM4C123GH6PM (64pin) is the package used on the EK-TM4C123GXL Launchpad evaluation board. 

  • Hi Charles,

    Thanks for the replying.

    There is no "PART_TM4C123GH6PZ" option in the list.

    I used "Add..." button to add "PART_TM4C123GH6PZ" and select.

    I have no idea if this is correct.

         

  • Hi,

      You can remove the PART_TM4C123GH6PM  and just keep PART_TM4C123GH6PZ.