Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3882

SDK • Re: RP2350: systick gotcha - FYI

$
0
0
I was talking strictly how the Arm SysTick works, there is a hidden cycle ... the first tick after reset is 0 ... only at the second one it loads RVR.
Let me show you with this snippet:

Code:

    unsigned int rvr, t1, t2, t3, t4, t5, t6;    systick_hw->csr=0b101;  // set processor clock + enable    for (rvr=0; rvr < 7; ++rvr) {        systick_hw->rvr = rvr;        systick_hw->cvr = 0;        t1 = systick_hw->cvr;        t2 = systick_hw->cvr;        t3 = systick_hw->cvr;        t4 = systick_hw->cvr;        t5 = systick_hw->cvr;        t6 = systick_hw->cvr;        printf("RVR=%u  %u  %u  %u  %u  %u  %u \n", rvr, t1,t2,t3,t4,t5,t6);    }
the relevant disassembly:

Code:

1000027c:f04f 21e0 mov.wr1, #3758153728@ 0xe000e000 10000280:614c      strr4, [r1, #20]  <<  systick_hw->rvr = rvr;10000282:2300      movsr3, #0   10000284:618b      strr3, [r1, #24]  <<   systick_hw->cvr = 0;10000286:698a      ldrr2, [r1, #24]  <<  t1 = systick_hw->cvr;10000288:698b      ldrr3, [r1, #24]  <<  t2 = systick_hw->cvr;1000028a:6988      ldrr0, [r1, #24]  <<  t3 = systick_hw->cvr;1000028c:698d      ldrr5, [r1, #24]  <<  t4 = systick_hw->cvr;1000028e:698e      ldrr6, [r1, #24]  <<  t5 = systick_hw->cvr;10000290:6989      ldrr1, [r1, #24]  <<  t6 = systick_hw->cvr;
and the result:
RVR=0 > 0 0 0 0 0 0
RVR=1 > 0 1 0 1 0 1
RVR=2 > 0 2 1 0 2 1
RVR=3 > 0 3 2 1 0 3
RVR=4 > 0 4 3 2 1 0
RVR=5 > 0 5 4 3 2 1
RVR=6 > 0 6 5 4 3 2

Statistics: Posted by gmx — Wed Sep 04, 2024 3:07 am



Viewing all articles
Browse latest Browse all 3882

Trending Articles