Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

using the timer in myrio with eclipse

Hi everyone!

I am trying to create a timer interrupt in myRIO using the Eclipse CDT that takes in a sensor reading every 0.005 sec. But I haven't been able to find much documentation about the register details for using the timer or counter in my RIO so that I can program it in C using Eclipse. The sample program for the TimerIRQ utilises the current calendar time so am not able to create any interrupt  that occurs more that once per second. 

Please do suggest any references or documents for the same if possible

 

Thank you

0 Kudos
Message 1 of 4
(4,258 Views)

Hi !

 

I realized a program in which there is a periodic interrupt. If it's what you want to do :

First, you download the examples in 'C support for Ni my RIO'  at :

http://www.ni.com/download/labview-myrio-toolkit-2014/4949/en/

 

Then you importe in Eclipse the example called : myRIO Example - TimerIRQ

 

In the file main.c, you have to add some lines (lines in bols style below) and also you must declare :

 

NiFpga_Session myrio_session;
const uint32_t timeoutValue = 200;                   // for 200 microsecondes between 2 IRQs for example

 

.....

 

/*
         * Stop the calling thread, wait until a selected IRQ is asserted.
         */
        Irq_Wait(threadResource->irqContext, TIMERIRQNO,
                 &irqAssert, (NiFpga_Bool*) &(threadResource->irqThreadRdy));

        NiFpga_WriteU32(myrio_session,IRQTIMERWRITE,timeoutValue); 
        NiFpga_WriteBool(myrio_session,IRQTIMERSETTIME,NiFpga_True);
        /*
         * If an IRQ was asserted.
         */
        if (irqAssert & (1 << TIMERIRQNO))
        {


           Here you place your interrupt program

            /*
             * Acknowledge the IRQ(s) when assertion is done.
             */
            Irq_Acknowledge(irqAssert);
        }

 

.....

 

 

 

   I hope this will help you...

 

  My problem is that I use this program to sample a signal and I want a sample rate of 100kS/s but I can't get less than 50 µs between 2 IRQs, if you have an idea !!

 

 

        Françoise

 

 

 

 

 

 

 

Message 2 of 4
(4,205 Views)

Hi Francoise

 

Thank you so much for the help. It works well now.

 

And I was able to generate 2 successive IRQs in 50 microseconds as well with your code. Just make sure that you do not have any 'print' statements inside the ISR, as they take a considerable amount of  time to get executed.

 

I used a 50 microsecond interval interrupt  and had a counter variable inside the interrupt service routine (with initial value 0) which kept incrementing every time the ISR is called. I then used a print statement which printed  once the counter reached a value of 20000, which means that the print statement executes every second. This seemed to work fine for me. Hope it helps

 

 

 

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

  Hi !

 

I am glad to know that now,  it works well for you !

 

My problem is that in my  interrupt service routine, I want to work with the analog IO and it seems to take too much time !!

 

0 Kudos
Message 4 of 4
(4,178 Views)