Hi TI Community,
First of all, I am using a TIVA EK-TM4C1294XL Evaluatioin Board, with TI-RTOS for TivaC product installed (version 2.16.0.08) and Code Composer Studio (v6.1.2.00015).
I am trying to set up a zero latency interrupt that fires repetitively(regularly) after a certain time (currently looking around 2 microseconds) with Timer2A. The interrupt will be used to perform some time critical operation. I have got the following information from pg116 of tn4c1294ncpdt data sheet -
Vector Number: 39 Interrupt Number: 23 Vector Address or Offset: 0x0000.009C Description: 16/32-Bit Timer 2A
I have been searching on the forum for similar topics and I have gone through the below threads:
https://e2e.ti.com/support/embedded/tirtos/f/355/p/508916/1847863#1847863
I was able to follow through the first answer of Aldabreu to created a HAL level timer interrupt but however not able to follow through with his last answer on creating a zero latency interrupt. I have attached snippets of my code for testing purposes in the empty_project.
Edited .cfg file to include the family specific Timer module. var Timer = xdc.useModule('ti.sysbios.family.arm.m3.Timer'); __________________________________________________________________ ...
#include <ti/sysbios/family/arm/m3/Timer.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
...
void hwi0_isr(UArg arg){ TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_3, 0x00); GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_3, 0x0F); } /* * ======== main ======== */ int main(void) { Task_Params taskParams; /* Call board init functions */ Board_initGeneral(); Board_initGPIO(); /* Construct heartBeat Task thread */ ... ... /* Init Timer interrupt and pin P3 for testing */ GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_3); /* Enable timer peripherial clock */ Timer_Params TimerParams; Timer_Handle myTimer; Hwi_Params hwiParams; Error_Block eb; Error_init(&eb); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER2); while (!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER2)) { } // initialise zero latency interrupt on timer Timer_Params_init(&TimerParams); TimerParams.period = 10; TimerParams.arg = 1; TimerParams.periodType = Timer_PeriodType_MICROSECS; //can also be in microseconds hwiParams.priority = 0; //zero latency interrupt, priority 0 TimerParams.hwiParams = &hwiParams; //Termination error when timerID = 0 and Timer_ANY, I tried 1,2, 23(interrupt number of Timer2A), 39(vector number of Timer2A). myTimer = Timer_create(*I am not too sure about this field, see above comment*, hwi0_isr, &TimerParams, &eb); if (myTimer == NULL) { System_abort("Timer create failed"); } /* Start BIOS */ BIOS_start(); return (0); }
My understanding is that the following line is configuring the interrupt to have a zero latency priority and the struct "hwiParams" is later passed into "TimerParams" as the config of Timer_create.
hwiParams.priority = 0; //zero latency interrupt, priority 0
I am getting the following error on launch after debug (no compile error as well) when I set TimerId to be 2 for Timer_create.
- ti.sysbios.family.arm.m3.Timer: line 162: E_invalidTimer: Invalid Timer Id 2
- Timer create failed
Thanks in advance for your help!
Gabriel
p.s I have also gone through software-dl.ti.com/.../Hwi.html