We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

1 post • Page 1 of 1
derGerd
Posts: 6
Joined: Fri Jul 25, 2025 6:51 am

PIO GPIO > 32

Tue Nov 11, 2025 11:30 am

Hello, I have a similar problem to the one in this thread: viewtopic.php?t=378871, except that I want to use a pin as an output. My PIO program:

Code: Select all

.program steppermotor
.wrap_target
	pull block
	mov x, osr; Anzahl Perioden kopieren
periode:
	set pins 1 [1] ; 1 CPU-Zyklus warten um jmp auszugleichen
	set pins 0 ; 
	jmp x-- periode ; braucht auch einen CPU-Zyklus
.wrap
% c-sdk{
	static inline void steppermotor_program_init(PIO pio, uint sm, uint offset, uint pin)
	{
	 pio_sm_config c = steppermotor_program_get_default_config(offset);
	 constexpr int PIO_FREQUENZ = 50000;
	 const float div = (float)clock_get_hz(clk_sys) / PIO_FREQUENZ;//Vorteiler berechnen
	 sm_config_set_clkdiv(&c, div);// Vorteiler für die State Machine setzen
	 pio_gpio_init(pio, pin);//PIO die Kontrolle über den Pin geben
	 sm_config_set_set_pins(&c, pin, 1);//Den Pin mit dem set Befehl steuerbar machen
	 pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);//Den Pin als Ausgang konfigurieren
	 pio_sm_init(pio, sm, offset, &c); //Konfiguration laden
	 pio_sm_put_blocking(pio, sm, 1000000);
	 pio_sm_set_enabled(pio, sm, true); //State machine starten
	}
%}
is supposed to turn the pin on and off for a given number of clock cycles, but the pin I want to use is GPIO46.

I'm using the following for initialization:

Code: Select all

if (pio_claim_free_sm_and_add_program_for_gpio_range(&steppermotor_program, &pio, &steppermotor_sm, &steppermotor_offset, pins.step, 1,
			true))
	{
		steppermotor_program_init(pio, steppermotor_sm, steppermotor_offset, pins.step);
	}
Unfortunately, this isn't working.

1 post • Page 1 of 1

Return to "SDK"

AltStyle によって変換されたページ (->オリジナル) /