SDK 2.1.0 : pio_get_dreq returning wrong value for pio2 #2195

Open
opened 2025-01-18 11:56:22 -06:00 by UKTailwind · 7 comments
UKTailwind commented 2025-01-18 11:56:22 -06:00 (Migrated from github.com)

As per the title. For all values of sm and tx/rx the values returned are those of PIO1

As per the title. For all values of sm and tx/rx the values returned are those of PIO1
peterharperuk commented 2025-01-24 06:55:29 -06:00 (Migrated from github.com)

I just checked this. The wifi pio code goes to pio 2 by default. As far as I can see the dreq values are correct DREQ_PIO2_TX0 and DREQ_PIO2_RX0.

I just checked this. The wifi pio code goes to pio 2 by default. As far as I can see the dreq values are correct DREQ_PIO2_TX0 and DREQ_PIO2_RX0.
UKTailwind commented 2025-01-24 08:05:35 -06:00 (Migrated from github.com)

Definitely fails for me as used below together with my workround which clearly would cause problems if it was working

   dma_channel_config c = dma_channel_get_default_config(dma_tx_chan);
   int pior=2, sm=0;
   PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2));
    channel_config_set_write_increment(&c, false);
    if(pior==2)channel_config_set_dreq(&c, 16+sm);
    else channel_config_set_dreq(&c, pio_get_dreq(pio, sm, true));
Definitely fails for me as used below together with my workround which clearly would cause problems if it was working > dma_channel_config c = dma_channel_get_default_config(dma_tx_chan); int pior=2, sm=0; PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2)); channel_config_set_write_increment(&c, false); if(pior==2)channel_config_set_dreq(&c, 16+sm); else channel_config_set_dreq(&c, pio_get_dreq(pio, sm, true));
lurch commented 2025-01-24 08:14:11 -06:00 (Migrated from github.com)

PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2));

This line seems to be duplicating the functionality of pio_get_instance? https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_pio/include/hardware/pio.h#L854

> `PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2));` This line seems to be duplicating the functionality of `pio_get_instance`? https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_pio/include/hardware/pio.h#L854
peterharperuk commented 2025-01-24 08:36:38 -06:00 (Migrated from github.com)

Definitely fails for me as used below together with my workround which clearly would cause problems if it was working

Sorry, that sentence doesn't scan.

    int pior=2, sm=0;
    PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2));
    /*channel_config_set_write_increment(&c, false);
    if(pior==2)channel_config_set_dreq(&c, 16+sm);
    else channel_config_set_dreq(&c, pio_get_dreq(pio, sm, true));*/
    printf("%u\n", pio_get_dreq(pio, sm, true)); // <<-- Shows 16

> Definitely fails for me as used below together with my workround which clearly would cause problems if it was working Sorry, that sentence doesn't scan. ``` int pior=2, sm=0; PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2)); /*channel_config_set_write_increment(&c, false); if(pior==2)channel_config_set_dreq(&c, 16+sm); else channel_config_set_dreq(&c, pio_get_dreq(pio, sm, true));*/ printf("%u\n", pio_get_dreq(pio, sm, true)); // <<-- Shows 16 ```
UKTailwind commented 2025-01-24 08:46:59 -06:00 (Migrated from github.com)

This is the code I am using which includes a workround for the bug
If there wasn't a bug I could simply use:

int pior=2, sm=0;
PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2));
channel_config_set_write_increment(&c, false);
channel_config_set_dreq(&c, pio_get_dreq(pio, sm, true));

but I can't because in my code pio_get_dreq(pio, sm, true) returns 8 when pio==pio2

This is the code I am using which includes a workround for the bug If there wasn't a bug I could simply use: > int pior=2, sm=0; PIO pio = (pior==0 ? pio0: (pior==1 ? pio1: pio2)); channel_config_set_write_increment(&c, false); channel_config_set_dreq(&c, pio_get_dreq(pio, sm, true)); but I can't because in my code pio_get_dreq(pio, sm, true) returns 8 when pio==pio2
peterharperuk commented 2025-01-24 09:36:08 -06:00 (Migrated from github.com)

I can't see how that's physically possible. One of us must be missing something.

I can't see how that's physically possible. One of us must be missing something.
kilograham commented 2025-02-02 12:58:03 -06:00 (Migrated from github.com)

moving to 2.2.0 as I can't see how this could be either

moving to 2.2.0 as I can't see how this could be either
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#2195
No description provided.