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

General • Re: Stepper control using Timers and PIO

$
0
0
Do you want something like this (completely untested)?

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 0
You'd write a 16 bit integer with value n-1 for n pulses, 50% duty cycle, to the FIFO.
And how do I set the PIO frequency give an output of exact frequency??
The 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.
I found this github example for the application
https://github.com/ahmsville/Pi-Pico-PI ... Controller

But the delay set in the code is 500uS and mine is 2.5uS so I should set the clk div to 75 which generates each pio clock pulse at 500nS. I just need to put a 1 in the FIFO and it should work

Statistics: Posted by akash614 — Tue May 06, 2025 3:40 am



Viewing all articles
Browse latest Browse all 8037

Trending Articles