Hi,
I have a code which loops around 32 times and toggle a pin (GP[9]). My system clock is 60MHz so I figure, given the code below, I should see the pin toggle at rate = 60MHz/(#of instructions * number of cycles per instruction).
_asmReadADC:
@BRC0_L = 32 || mmap() ; Generate 16 cycles sclock.
blockrepeat{
T0 = *port(#0x1c0a) -------- read serial port 1 register and put it in T0 (One system clock cycle to execute)
T0 ^= 0x0200 ;BIT9 -------- Toggle data bit in GP[9] (One System clock cycle to execute)
*port(#0x1c0a) = T0 -------- Toggle pin GP[9] (One system clock cycle to execute)
}
T0 = *port(#0x1c0a);
T0 |= BIT9 ; Raise sclock high
*port(#0x1c0a) = T0
return
Two loops equal to one cycle (on and off) on GP[9]. So, given my system clock is 60MHz, I should see GP[9] toggles at 60MHz/(2 loops * 3 cycles per loop) = 10MHz. However, I'm only seeing 3.3MHz (on the scope.) This mean that the code in the repeat block above is actually taking 9 system clock cycles to execute. How is this so? Are there clock cycles in the repeat block (code shown above) that I haven't account for?
Thanks,
Lam
P.S. Here is the disassembly code for the block of code shown above.
030930 $asmReadADC.asm:8:18$, asmReadADC:
030930 e63420_98 MOV #32,mmap(@BRC0)
030934 0e0008 RPTB 0x3093f
030937 a4511c0a MOV port(#01c0ah),T0
03093B 7f020044 XOR #512,T0,T0
03093F c4511c0a MOV T0,port(#01c0ah)
030943 a4511c0a MOV port(#01c0ah),T0
030947 7e020044 OR #512,T0,T0
03094B c4511c0a MOV T0,port(#01c0ah)
03094F 4804 RET