Hi all,
I just want to try use Periodic Interrupt Timer in my board. I was only changed/added below lines in default SDK example(pit).
volatile uint32_t globalCounter = 0; //new line for test
void PIT_LED_HANDLER(void)
{
/* Clear interrupt flag.*/
PIT_ClearStatusFlags(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL, kPIT_TimerFlag);
pitIsrFlag = true;
globalCounter++; //new line for test
__DSB();
}
...
..
.
/* Start channel 0 */
PRINTF("\r\nStarting channel No.0 ...");
PIT_StartTimer(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL);
uint64_t startVal = PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL);
while (true)
{
/* Check whether occur interupt and toggle LED */
if (true == pitIsrFlag && globalCounter < 6)
{
PRINTF("\r\n Channel No.0 interrupt is occurred !");
LED_TOGGLE();
pitIsrFlag = false;
}
if(globalCounter >= 6)//new lines below
{
uint64_t endVal = PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL);
uint64_t resultVal = endVal - startVal;
uint64_t usecVal = COUNT_TO_USEC(resultVal, PIT_SOURCE_CLOCK);
}
}
I am just waiting for usecVal will be equal to the 5 sec so about 5000000 mikrosecond. I am just trying to use ticks for chronometer usage in my project. But in this code neither usecVal is equal 5sec or resultVal is equal to tick corresponding 5sec after run the project. What is wrong with that? All codes belowed in attachment.
Thanks and Regards.
解決済! 解決策の投稿を見る。
Hi @Lukas_Frank ;
PIT_GetCurrentTimerCount is used to read current timer counting value.
COUNT_TO_USEC is used to convert a raw count alue to microsecond.
Please see below line for the usage.
uint32_t usecVal = COUNT_TO_USEC((uint64_t)PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL), PIT_SOURCE_CLOCK);
PRINTF("\r\n useVal is %d",usecVal);
Regards
Daniel
Hi @Lukas_Frank ;
PIT_GetCurrentTimerCount is used to read current timer counting value.
COUNT_TO_USEC is used to convert a raw count alue to microsecond.
Please see below line for the usage.
uint32_t usecVal = COUNT_TO_USEC((uint64_t)PIT_GetCurrentTimerCount(DEMO_PIT_BASEADDR, DEMO_PIT_CHANNEL), PIT_SOURCE_CLOCK);
PRINTF("\r\n useVal is %d",usecVal);
Regards
Daniel