Hi, i have this code hos do i calculate the frquency and pulse width?
from machine import Pin from rp2 import PIO, StateMachine, asm_pio import time
led = Pin("LED", Pin.OUT, value=0)
@asm_pio(set_init=PIO.OUT_LOW) def square(): # Cycles: 1 + 1 + 6 + 32 * (30 + 1) = 1000 irq(rel(0)) set(pins, 1) set(x, 31) [5] label("delay_high") nop() [5] jmp(x_dec, "delay_high")
# Cycles: 1 + 7 + 32 * (30 + 1) = 1000 set(pins, 0) set(x, 31) [5] label("delay_low") nop() [1] jmp(x_dec, "delay_low")
sm = StateMachine(0, square, freq=2000, set_base=Pin(0))
sm.irq(lambda p: led.toggle())
sm.active(1)