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

General • PIO reading and comparing pin values

$
0
0
Hi everyone,
I'm trying to detect a bit pattern by reading in values at certain times and comparing them to an expected pattern. If it doesn't match, I'm setting a pin high, and try again on the next falling edge. However the comparison for the jump is always true, even when the right pattern is applied. I'm expecting a 0 during the first "in pins, 1" and a 1 during the second in operation. This should leave me with the value 1 in the ISR which is also the value in the Y scratch register to compare against. Any help/feedback would be appreciated.

Code:

.program Rx_sm.side_set 1 opt    set pins, 1    set Y, 0b00001wait_edge:    wait 1 pin 0 side 1    wait 0 pin 0 [3].wrap_target    set X, 0    in pins, 1 [7]    nop [3]    in pins, 1    mov X, ISR    jmp X!=Y wait_edge    set pins 0 [7].wrap% c-sdk {void Rx_sm_program_init(PIO pio, uint sm, uint offset, uint RxPin, uint detunePin, float div) {   pio_gpio_init(pio, detunePin);   pio_sm_set_consecutive_pindirs(pio, sm, detunePin, 1, true);   pio_sm_config c = Rx_sm_program_get_default_config(offset);   sm_config_set_set_pins(&c, detunePin, 1);   sm_config_set_sideset_pins(&c, detunePin);   sm_config_set_in_pins(&c, RxPin);   sm_config_set_clkdiv(&c, div);   pio_sm_init(pio, sm, offset, &c);}%}

Statistics: Posted by brwayne — Tue Aug 27, 2024 12:33 pm — Replies 2 — Views 53



Viewing all articles
Browse latest Browse all 7420

Trending Articles