Question about Generic Timer usage

Discussion and questions about programming with Ultibo.
asjsmile
Posts: 14
Joined: Fri May 03, 2019 10:49 am

Question about Generic Timer usage

Postby asjsmile » Thu Jul 18, 2019 8:54 am

Hi Ultibo Team,

now, i am using Generic timer in CPU1 as below.

Code: Select all

    { Timer1 Setting } // Timer1_Interval = 1000 for 1ms
    RequestFIQ(CPU_ID_1,BCM2837_IRQ_LOCAL_ARM_CNTVIRQ,@TimerCallback1,nil);
    Cnt_State_Cpu1:=ARMv8GetTimerState(ARMV8_CP15_C14_CNTV);
    Cnt_State_Cpu1:=Cnt_State_Cpu1 and not(ARMV8_CP15_C14_CNT_CTL_IMASK);
    Cnt_State_Cpu1:=Cnt_State_Cpu1 or ARMV8_CP15_C14_CNT_CTL_ENABLE;
    ARMv8SetTimerState(ARMV8_CP15_C14_CNTV,Cnt_State_Cpu1);
    ARMv8SetTimerValue(ARMV8_CP15_C14_CNTV,Timer1_Interval);


When Timer1_Interval = 1000, the timer interrupt is 1ms.
but in case of Timer1_Interval = 2000, the timer interrupt is not 2ms it's about 4ms.

I don't know why ?

Could you recommend for precise timer interrupt usage ?

Best regards
SJ
User avatar
Ultibo
Site Admin
Posts: 2291
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Question about Generic Timer usage

Postby Ultibo » Fri Jul 19, 2019 9:51 am

asjsmile wrote:When Timer1_Interval = 1000, the timer interrupt is 1ms.
but in case of Timer1_Interval = 2000, the timer interrupt is not 2ms it's about 4ms.

I don't know why ?

Could you recommend for precise timer interrupt usage ?

There's nothing we can think of that would cause these results so we'll have to test it and see what we find.

One question, what result do you get if you use IRQ instead of FIQ?
Ultibo.org | Make something amazing
https://ultibo.org
User avatar
Ultibo
Site Admin
Posts: 2291
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Question about Generic Timer usage

Postby Ultibo » Sat Jul 20, 2019 12:51 am

Ultibo wrote:There's nothing we can think of that would cause these results so we'll have to test it and see what we find.

Okay so we've created a test that runs the Generic Timer at various intervals and records the results.

For an interval of 1000 it takes exactly 1 million microseconds for 1000 timer interrupts to occur which is 1ms per interrupt.
For an interval of 2000 it takes exactly 1 million microseconds for 500 timer interrupts to occur which is 2ms per interrupt.
And for an interval of 4000 it takes exactly 1 million microseconds for 250 timer interrupts to occur which is 4ms per interrupt.

For completeness we tested with both IRQ and FIQ and got the same results on both, our test ran the timer interrupt on CPU1 and a separate thread on CPU2 which kept track of the results.

Can you provide any more information on your results, what else do you have occurring at the same time, are you able to reproduce this in a simplified example?

Anything you can tell us might be helpful in understanding your result.
Ultibo.org | Make something amazing
https://ultibo.org
asjsmile
Posts: 14
Joined: Fri May 03, 2019 10:49 am

Re: Question about Generic Timer usage

Postby asjsmile » Mon Jul 22, 2019 2:50 am

Dear Ultibo team,

sorry, there was my mistake to measure the time.

when i set 2000, the time is 2ms.

best regards

SJ
User avatar
Ultibo
Site Admin
Posts: 2291
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Question about Generic Timer usage

Postby Ultibo » Mon Jul 22, 2019 11:22 pm

asjsmile wrote:sorry, there was my mistake to measure the time.

when i set 2000, the time is 2ms.

No problem SJ, as long as it is working now.
Ultibo.org | Make something amazing
https://ultibo.org

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests