PIO GPIO > 32
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:
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:
Unfortunately, this isn't working.
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
}
%}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);
}
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion