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

General • PIO program length help.

$
0
0
Hello, I´m new to the forum and joined seeking help for this issue. I have looked around and haven´t found any similar posts so I created this New Topic.

I need the following PIO program to mirror the inputs from some pins into other pins:

Code:

#pragma once#if !PICO_NO_HARDWARE#include "hardware/pio.h"#endif// ---------- //// pin_mirror //// ---------- //#define pin_mirror_wrap_target 0#define pin_mirror_wrap 2static const uint16_t pin_mirror_program_instructions[] = {            //     .wrap_target    0x4008, //  0: in     pins, 8                        0xa0e6, //  1: mov    osr, isr                       0x6008, //  2: out    pins, 8                                //     .wrap};#if !PICO_NO_HARDWAREstatic const struct pio_program pin_mirror_program = {    .instructions = pin_mirror_program_instructions,    .length = 3,    .origin = -1,};static inline pio_sm_config pin_mirror_program_get_default_config(uint offset) {    pio_sm_config c = pio_get_default_sm_config();    sm_config_set_wrap(&c, offset + pin_mirror_wrap_target, offset + pin_mirror_wrap);    return c;}

If I set the length to 3, the code doesn`t reflect the inputs to the outputs. If I set the length to 4 (discovered by acident), the code works correctly.


Any Ideas why this is the case?

Statistics: Posted by Velez — Fri Jan 17, 2025 5:12 pm — Replies 1 — Views 44



Viewing all articles
Browse latest Browse all 4700

Trending Articles