10-17-2014 03:42 AM
Hello,
i've tried TimerIRQ example and i've encountered following problem: the comment in main.c says:
* Demonstrates how to use the timer IRQ. Once the timer IRQ occurs ( every 5 s), print
* the IRQ number,
However, th IRQ occurs only once, and i'd like it to happen repeatedly. Further comment in program says:
/*
* Configure the timer IRQ. The Time IRQ occurs only once after Timer_IrqConfigure().
* If you want to trigger the timer IRQ repeatedly, use this function every time you trigger the IRQ.
* Or you can put the IRQ in a loop.
* Return a status message to indicate if the configuration is successful. The error code is defined in IRQConfigure.h.
*/
Unfortunately, i can't find Timer_IrqConfigure() function or solve this problem in any other way. I'd really appreciate some help on this matter.
And second question: is there a way to make function time() from time.h to return value in miliseconds or microseconds?
Greetings
06-06-2016 09:53 AM
Hi
This post is about 2 years old and nobldy has commented. I came across this post a few days ago and tried to repeat the timer interrupt successfully, so thought I should explain for the benefit of others:
The timer used is a one shot timer. This means you set a time and it starts counting down and raises an interrupt when the count reaches zero. If you want another interrupt, you must rest the timer again - there is no auto_reload mechanism. This is explained in comments already quoted by you.
What I did was to call the function
status = Irq_RegisterTimerIrq(&irqTimer0, &irqThread0.irqContext, timeoutValue); ( in addition to calling it from the main as given in the example.)
inside the
Timer_Irq_Thread()
It raised interrupt twice. Then I used a loop around this function call and it repeats the timer interrupt for as long as
irqThreadRdy is True.
Relevent code given here:
if (irqAssert & (1 << TIMERIRQNO))
{
printf("IRQ%d,%d\n", TIMERIRQNO, ++irqCount);
/*
* Acknowledge the IRQ(s) when assertion is done.
*/
Irq_Acknowledge(irqAssert);
}
/* This code added to repeat interrupt*/
// unregister the irq
status = Irq_UnregisterTimerIrq(&irqTimer0, irqThread0.irqContext);
if (status != NiMyrio_Status_Success)
{
printf("CONFIGURE ERROR: %d\n", status);
printf("Clear configuration of Timer IRQ failed.");
return status;
}
// Reregister the IRQ
status = Irq_RegisterTimerIrq(&irqTimer0, &irqThread0.irqContext, timeoutValue);