Oct 09, 2020
01:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 09, 2020
01:22 AM
Hi,
I am new to Aurix and using Tricore TC275TP-64.
I want to know(I saw T3 can be reload using T2/T4 timers with relaod values in example project) whether we can use T2, T3, T4 timers independely with different reload time value in timer mode to create interrupts.
I understood, I can get interrupts when these timers overflow(65535) but can I choose the value to timeout?
I was trying as below to generate 200ms and 1000ms interrupts.
void initGpt12Timer(void)
{
/* Initialize the GPT12 module */
IfxGpt12_enableModule(&MODULE_GPT120); /* Enable the GPT12 module */
IfxGpt12_setGpt1BlockPrescaler(&MODULE_GPT120, IfxGpt12_Gpt1BlockPrescaler_16); /* Set GPT1 block prescaler */
/* Initialize the Timer T3 */
IfxGpt12_T3_setMode(&MODULE_GPT120, IfxGpt12_Mode_timer); /* Set T3 to timer mode */
IfxGpt12_T3_setTimerDirection(&MODULE_GPT120, IfxGpt12_TimerDirection_down); /* Set T3 count direction */
IfxGpt12_T3_setTimerPrescaler(&MODULE_GPT120, 2); /*prescalar-64; Set T3 input prescaler */
IfxGpt12_T3_setTimerValue(&MODULE_GPT120,19531); /* 200ms */
/* Initialize the interrupt */
volatile Ifx_SRC_SRCR *src = IfxGpt12_T3_getSrc(&MODULE_GPT120); /* Get the interrupt address */
IfxSrc_init(src, IfxSrc_Tos_cpu1, 1); /* Initialize service request */
IfxSrc_enable(src); /* Enable GPT12 interrupt */
IfxGpt12_T3_run(&MODULE_GPT120, IfxGpt12_TimerRun_start); /* Start the timer */
/* Initialize the Timer T2 */
IfxGpt12_T2_setMode(&MODULE_GPT120, IfxGpt12_Mode_timer); /* Set T2 to timer mode */
IfxGpt12_T2_setTimerDirection(&MODULE_GPT120, IfxGpt12_TimerDirection_down); /* Set T2 count direction */
IfxGpt12_T2_setTimerPrescaler(&MODULE_GPT120, 3); /* Prescalar:128 - T2 input prescaler */
IfxGpt12_T2_setTimerValue(&MODULE_GPT120, 48828); /* Set T2 start value */
/* Initialize the interrupt */
src = IfxGpt12_T2_getSrc(&MODULE_GPT120); /* Get the interrupt address */
IfxSrc_init(src, IfxSrc_Tos_cpu1, 2); /* Initialize service request */
IfxSrc_enable(src); /* Enable GPT12 interrupt */
IfxGpt12_T2_run(&MODULE_GPT120, IfxGpt12_TimerRun_start); /* Start the timer */
}
IFX_INTERRUPT(T2ISR, 0, 1)
{....
}
IFX_INTERRUPT(T3ISR, 0, 2)
{...
}
Currently my ISR are hittling on 671ms and 1342ms.
I would like to use 5 different timer values through out my program to schedule different state machines in code.
I am new to Aurix and using Tricore TC275TP-64.
I want to know(I saw T3 can be reload using T2/T4 timers with relaod values in example project) whether we can use T2, T3, T4 timers independely with different reload time value in timer mode to create interrupts.
I understood, I can get interrupts when these timers overflow(65535) but can I choose the value to timeout?
I was trying as below to generate 200ms and 1000ms interrupts.
void initGpt12Timer(void)
{
/* Initialize the GPT12 module */
IfxGpt12_enableModule(&MODULE_GPT120); /* Enable the GPT12 module */
IfxGpt12_setGpt1BlockPrescaler(&MODULE_GPT120, IfxGpt12_Gpt1BlockPrescaler_16); /* Set GPT1 block prescaler */
/* Initialize the Timer T3 */
IfxGpt12_T3_setMode(&MODULE_GPT120, IfxGpt12_Mode_timer); /* Set T3 to timer mode */
IfxGpt12_T3_setTimerDirection(&MODULE_GPT120, IfxGpt12_TimerDirection_down); /* Set T3 count direction */
IfxGpt12_T3_setTimerPrescaler(&MODULE_GPT120, 2); /*prescalar-64; Set T3 input prescaler */
IfxGpt12_T3_setTimerValue(&MODULE_GPT120,19531); /* 200ms */
/* Initialize the interrupt */
volatile Ifx_SRC_SRCR *src = IfxGpt12_T3_getSrc(&MODULE_GPT120); /* Get the interrupt address */
IfxSrc_init(src, IfxSrc_Tos_cpu1, 1); /* Initialize service request */
IfxSrc_enable(src); /* Enable GPT12 interrupt */
IfxGpt12_T3_run(&MODULE_GPT120, IfxGpt12_TimerRun_start); /* Start the timer */
/* Initialize the Timer T2 */
IfxGpt12_T2_setMode(&MODULE_GPT120, IfxGpt12_Mode_timer); /* Set T2 to timer mode */
IfxGpt12_T2_setTimerDirection(&MODULE_GPT120, IfxGpt12_TimerDirection_down); /* Set T2 count direction */
IfxGpt12_T2_setTimerPrescaler(&MODULE_GPT120, 3); /* Prescalar:128 - T2 input prescaler */
IfxGpt12_T2_setTimerValue(&MODULE_GPT120, 48828); /* Set T2 start value */
/* Initialize the interrupt */
src = IfxGpt12_T2_getSrc(&MODULE_GPT120); /* Get the interrupt address */
IfxSrc_init(src, IfxSrc_Tos_cpu1, 2); /* Initialize service request */
IfxSrc_enable(src); /* Enable GPT12 interrupt */
IfxGpt12_T2_run(&MODULE_GPT120, IfxGpt12_TimerRun_start); /* Start the timer */
}
IFX_INTERRUPT(T2ISR, 0, 1)
{....
}
IFX_INTERRUPT(T3ISR, 0, 2)
{...
}
Currently my ISR are hittling on 671ms and 1342ms.
I would like to use 5 different timer values through out my program to schedule different state machines in code.
- Tags:
- IFX
2 Replies
Oct 10, 2020
11:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 10, 2020
11:58 AM
I am not sure where you got your timeout values. Typically the frequency of the SPB is 100MHz and this is the clock source for the GPT12.
Here is an example to configure T2 (200ms) and T3 (1 second).
Port pins P00.0 and P00.1 show the timeouts by toggling pins in their ISR's
The ISR's
Scope plot
Here is an example to configure T2 (200ms) and T3 (1 second).
Port pins P00.0 and P00.1 show the timeouts by toggling pins in their ISR's
#define T2_RELOAD 9765
#define T3_RELOAD 48828
volatile uint32 T2_ticks;
volatile uint32 T3_ticks;
void GPT12_Init(void){
uint16 cpuWdtPassword = IfxScuWdt_getCpuWatchdogPassword();
IfxScuWdt_clearCpuEndinit(cpuWdtPassword);
GPT120_CLC.U = 0; /* enable peripheral and allow sleep mode */
(void) GPT120_CLC.U;
IfxScuWdt_setCpuEndinit(cpuWdtPassword);
P00_IOCR0.B.PC0 = PCx_Output_PushPull_gpio;
P00_IOCR0.B.PC1 = PCx_Output_PushPull_gpio;
/* Enter interrupt level and initialize both the SCR and jump table entry */
SRC_GPT120T2.U = TOS_CPU0 | SRE_ON | SRPN_CPU0_GPT120_T2;
/* Enter interrupt level and initialize both the SCR and jump table entry */
SRC_GPT120T3.U = TOS_CPU0 | SRE_ON | SRPN_CPU0_GPT120_T3;
/* setup the */
Ifx_GPT12_T3CON t3con =
{
.B.T3I = TxI_TimerInputPrescaler_64,
.B.T3M = TxM_TimerMode,
.B.T3R = TxR_TimerRun_stop,
.B.T3UD = TxUD_CountsDown,
.B.T3UDE = TxUDE_TimerDirectionSource_internal,
.B.T3OE = 0,
.B.T3OTL = 0,
.B.BPS1 = BPS1_DivBy32,
.B.T3EDGE = 0,
.B.T3CHDIR = 0,
.B.T3RDIR = TxUD_TimerDirection_down
};
GPT120_T3CON.U = t3con.U;
(void) GPT120_T3CON.U;
/* setup the */
Ifx_GPT12_T2CON t2con =
{
.B.T2I = TxI_TimerInputPrescaler_64,
.B.T2M = TxM_TimerMode,
.B.T2R = TxR_TimerRun_stop,
.B.T2UD = TxUD_CountsDown,
.B.T2UDE = TxUDE_TimerDirectionSource_internal,
.B.T2RC = 0,
.B.T2IRDIS = 0,
.B.T2EDGE = 0,
.B.T2CHDIR = 0,
.B.T2RDIR = 0
};
GPT120_T2CON.U = t2con.U;
(void) GPT120_T2CON.U;
/* T2 start value */
GPT120_T2.U = T2_RELOAD;
/* T3 start value */
GPT120_T3.U = T3_RELOAD;
/*stop timers when debugger stops */
GPT120_OCS.U = 0x11000000;
/* start timer 2 */
GPT120_T2CON.B.T2R = 1;
/* start timer 3 */
GPT120_T3CON.B.T3R = 1;
}
The ISR's
IFX_INTERRUPT(GPT12_T2ISR, VECTAB0, SRPN_CPU0_GPT120_T2);
void GPT12_T2ISR(void)
{
GPT120_T2.U = T2_RELOAD;
P00_OMR.U = PORT_TGL_P0;
T2_ticks++;
}
IFX_INTERRUPT(GPT12_T3ISR, VECTAB0, SRPN_CPU0_GPT120_T3);
void GPT12_T3ISR(void)
{
GPT120_T3.U = T3_RELOAD;
P00_OMR.U = PORT_TGL_P1;
T3_ticks++;
}
Scope plot
Oct 11, 2020
09:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 11, 2020
09:52 AM
Thanks a lot. It is working now. I was not reloading the timer in ISR earlier.
This widget could not be displayed.