Do you want something like this (completely untested)?You'd write a 16 bit integer with value n-1 for n pulses, 50% duty cycle, to the FIFO.Code:
; pull out 16 bit integers from FIFO, and generate n+1 pwm pulses; autopull, joined FIFO.side_set 1.wrap_targetout y, 16 side 0loop_start:jmp y-- loop side 1.wraploop:jmp loop_start side 0The PIO runs off the system clock, and you can divide it down with the SMx_CLKDIV registers. So for the PIO program from above running at 400 kHz for a 200 kHz output wave at a system clock of 100 MHz the divider would be 250.And how do I set the PIO frequency give an output of exact frequency??
I am using a Pico 2 so frequency is 150Mhz and each instruction is a cycle so 3 cycles each cycle is 2.5us then 7.5us would give clk div of 1125.
So I just need to use sm_put_blocking to give a value and this does the job
Statistics: Posted by akash614 — Mon May 05, 2025 5:05 pm