TM4C1294KCPDT: TI-RTOS issue with BIOS crash

Part Number: TM4C1294KCPDT

Dear Ti,

I am facing issue with implementing timer with interrupt , when I assigns Timer ISR my code crashes and i.e BIOS() Function gets crash. Please help me to resolve.

I have attached Project. 

Ti RTOS :- tiva 2.16.1.14

Compiler : -GNU v7.2.1 (linaro)

Regards

Khodidas
SUBMODULE_V2.zip

  • When using SYS/BIOS the SYS/BIOS Hwi module should be used to plug an interrupt instead of using a TivaWare IntRegister function. See [FAQ] Can I update the vector table with IntRegister when using TI-RTOS?

  • Dear Chester,

    I am unable to understand this resolution , might it need efforts more from my side, meanwhile, if further steps by step solution for this you have then please share it., so we can move ahead in the project.

    Regards

    Khodidas 

  • Hi,

      In your code you plug interrupt vector yourself. By doing this, you corrupt the vector table that is managed by the BIOS. This is what the post Chester was referring to explain. You need to let BIOS handles all the HWI. 

    //
    // Setup the interrupts for the timer timeouts.
    //
    TimerIntRegister(TIMER0_BASE,TIMER_A,Timer0IntHandler);
    IntRegister(INT_TIMER0A,Timer0IntHandler);
    IntEnable(INT_TIMER0A);
    TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    IntMasterEnable();

    Below is an example for TM4C123 setting up timer 2. The BIOS registers the timer vector ledToggle using Timer_create(). You cannot use intRegister(). Please read Chester's reference post again. I think it explains everything.

    Timer_create(2,(Timer_FuncPtr)ledToggle,&Timer2,NULL);

    //----------------------------------------
    // BIOS header files
    //----------------------------------------
    #include <xdc/std.h>  						//mandatory - have to include first, for BIOS types
    #include <ti/sysbios/BIOS.h> 				//mandatory - if you call APIs like BIOS_start()
    #include <xdc/runtime/Log.h>				//needed for any Log_info() call
    #include <xdc/cfg/global.h> 				//header file for statically defined objects/handles
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Error.h>
    #include <ti/sysbios/hal/Hwi.h>
    #include <ti/sysbios/hal/Timer.h>
    
    //------------------------------------------
    // TivaWare Header Files
    //------------------------------------------
    #include <stdint.h>
    #include <stdbool.h>
    
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "inc/hw_ints.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/timer.h"
    
    
    //----------------------------------------
    // Prototypes
    //----------------------------------------
    void hardware_init(void);
    void ledToggle(void);
    
    
    //---------------------------------------
    // Globals
    //---------------------------------------
    volatile int16_t i16ToggleCount = 0;
    
    
    //---------------------------------------------------------------------------
    // main()
    //---------------------------------------------------------------------------
    void main(void)
    {
    
        Timer_Params Timer2;
        Timer_Handle myTimer;
    
       hardware_init();							// init hardware via Xware
    
       Timer_Params_init(&Timer2);
       Timer2.arg=0;
       Timer2.period=100000;
       Timer2.periodType=Timer_PeriodType_MICROSECS;
       myTimer=Timer_create(2,(Timer_FuncPtr)ledToggle,&Timer2,NULL);
       Timer_start(myTimer);
    
       BIOS_start();
    
    }
    
    
    //---------------------------------------------------------------------------
    // hardware_init()
    //
    // inits GPIO pins for toggling the LED
    //---------------------------------------------------------------------------
    void hardware_init(void)
    {
    //	uint32_t ui32Period;
    
    	//Set CPU Clock to 40MHz. 400MHz PLL/2 = 200 DIV 5 = 40MHz
    	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    
    	// ADD Tiva-C GPIO setup - enables port, sets pins 1-3 (RGB) pins for output
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
    
    	// Turn on the LED
    	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 4);
    
    	// Timer 2 setup code
    //	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);			// enable Timer 2 periph clks
    //	TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);		// cfg Timer 2 mode - periodic
    
    //	ui32Period = (SysCtlClockGet() /2);						// period = CPU clk div 2 (500ms)
    //	TimerLoadSet(TIMER2_BASE, TIMER_A, ui32Period);			// set Timer 2 period
    
    //	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);		// enables Timer 2 to interrupt CPU
    
    //	TimerEnable(TIMER2_BASE, TIMER_A);						// enable Timer 2
    
    }
    
    
    //---------------------------------------------------------------------------
    // ledToggle()
    //
    // toggles LED on Tiva-C LaunchPad
    //---------------------------------------------------------------------------
    void ledToggle(void)
    {
        TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);			// must clear timer flag FROM timer
    
    	// LED values - 2=RED, 4=BLUE, 8=GREEN
    	if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))
    	{
    		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
    	}
    	else
    	{
    		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
    	}
    
    	i16ToggleCount += 1;									// keep track of #toggles
    
    	Log_info1("LED TOGGLED [%u] TIMES",i16ToggleCount);		// send toggle count to UIA
    
    }

  • Hi, Charles,

    Thank you for support, we will test it soon and update accordingly.

    Regards

    Khodidas

  • Hi, Charles,

    you provided solution works.

    Thanks for great support..

    Regards 

    Khodidas