PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

What does discard mean when the NewAsyncTimer functions count elapses?

I have a PXI system with a PXIe8101 controller running with a real-time OS. I am having trouble with the asynchronous timer. I have a question about the count parameter in the function NewAsyncTimer(). The documentation says " Specifies teh number of timer events to be generated before the timer is automatically discarded."

What does it mean by "discarded"?

Does this mean it is "discarded" like when you call the function DiscardAsyncTimer() and it removes it from the list of existing timers?

 

Another question?

I created my timer like this:

 gRegCalMainLoopID = NewAsyncTimer (1e-03, -1, 0, RegCalProcessCntrlLoop, 0);

I belive this will set the priority to THREAD_PRIORITY_HIGHEST (2).

Since I set the initialState parameter to 0 it should not make call the call back function until I set teh ASYNC_ATTR_ENABLED to 1.

I send a command to do this and it makes this call:

  timerStatus = SetAsyncTimerAttribute( gRegCalMainLoopID,ASYNC_ATTR_ENABLED,1);  // this starts the timer interrupt

 

My problem is the timer function is never called with teh event = to EVENT_TIMER_TICK.

Here is my timer callback function:

int CVICALLBACK RegCalProcessCntrlLoop (int reserved, int timerId, int event, void *callbackData, int eventData1, int eventData2)
{
 switch(event)
 {
  case EVENT_TIMER_TICK:

 

 

The only other timer I have running in my system is in RTmain(). But it should be at a lower priority so the higher priority timer callback should not get blocked.

Her is part of my RTmain()

void CVIFUNC_C RTmain (void)
{
 if (InitCVIRTE (0, 0, 0) == 0)
  return;    /* out of memory */

 /*************************** Initialization code. ****************************/
 gDone=0; // when it is set to one the application is exited.
 // create callback timers
 CreateCallbackTimers();  // here is where I call the NewAsyncTimer() function above
 
 // initialize DMM digital multi-meter
 init_dmm();
 
 init_pxi_gpib();
 /*********************** END OF Initialization code. *************************/
 
 
 while (!RTIsShuttingDown () && !gDone)
 {
  /* Your code. */

  /* Sleep for some amount of time to give the desired loop rate */
  /* and to allow lower priority threads to run.                 */
  SleepUS (100);
  ProcessSystemEvents ();


 }

 

Any ideas what might be going on?

 

 

0 Kudos
Message 1 of 3
(4,298 Views)

Hi DPearce,

 

It does seem that the timer will be discarded in the same way as DiscardAsyncTimer meaning that the timer will no longer be registered or active after being called a specific number of times. Is there a specific aspect of the count parameter that you are curious about?

 

For Real Time systems a priority level of 2 is not necessarily the Highest Priority Thread and more information can be found in the help topic NewAsyncTimerWithPriority.

 

Have you seen if you are able to capture the Event Discard event as well?


Milan
0 Kudos
Message 2 of 3
(4,277 Views)

Found my bonehead mistake. I called SuspendAsyncTimerCallbacks() before I created my timer:

gRegCalMainLoopID = NewAsyncTimer (1e-03, -1, 0, RegCalProcessCntrlLoop, 0);

 

but, I never called ResumeAsyncTimerCallbacks() .

 

I did it because I wanted my  async timers would start at the same time. I read this somewhere but now I cannot find where I found that information. I guess that is what will happen.

 

So now everything seems to be working ok.

 

I am not sure why you would want the timer to be discarded because the count parameter was exceeded. For now I am always setting the count parameter to -1.

0 Kudos
Message 3 of 3
(4,274 Views)