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

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.

Statistics: Posted by Tharre — Sun May 04, 2025 6:20 pm



Viewing all articles
Browse latest Browse all 8374

Trending Articles