Closed
Description
Setting a low frequency that would generate a high number of decimal places causes the clock to be off but more than jitter.
sm = rp2.StateMachine(0, irq_test, freq=1907)
The edge case of freq=1907 generates tens of thousands of interrupts when expecting around 2000. Appears to be rounding issue more than just jitter?
Sample code:
import time
import rp2
i=int(0)
def i_inc(q):
global i
i += 1
#print(q.irq().flags())
@rp2.asm_pio()
def irq_test():
nop() [31] # 32 cyclces
nop() [31] # 64
nop() [31] # 96
nop() [2] # 99
irq(0) # 100 cycles
nop() [31]
nop() [31]
nop() [31]
nop() [2]
irq(1)
# 1907 causes a crazy amount of interrrupts.
sm = rp2.StateMachine(0, irq_test, freq=1907)
rp2.PIO(0).irq(i_inc)
sm.active(1)
time.sleep(1)
sm.active(0)
rp2.PIO(0).irq()
print(i)