piolib: Please add some method of unblocking DMA write

Open
#117 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
c
Domain
embedded-iot

Research direction

Start with the piolib implementations or documentation for pio_sm_config_xfer and pio_sm_xfer_data, then reproduce the 1 ms and random-gap behavior using the issue's transfer loops. Done means providing a documented, usable way to keep DMA writes supplied without gaps and explaining the final pio_sm_config_xfer argument, with validation of continuous output.

Written by the indexing model from the issue text.

Description

All I want to do is stream data without gaps but it doesn't seem possible on RP1 pio.

I set a large buffer:
#define BUF_SIZE 32768
uint8_t databuf[BUF_SIZE];
pio_sm_config_xfer(pio, sm, PIO_DIR_TO_SM, BUF_SIZE, 1);
while (1) {
pio_sm_xfer_data(pio, sm, PIO_DIR_TO_SM, sizeof(databuf), databuf);
sleep_ms(1); //simulate some calculation here
}

This works fine but the sleep_ms(1) inserts 1ms delay even though packet is 42ms long.

Doing:
while (1) {
pio_sm_xfer_data(pio, sm, PIO_DIR_TO_SM, sizeof(databuf), databuf);
}

In attempts to do continous data out, adds random blips of 100us and up to 5ms spacing.

Is there anyway around this eg automatic ring buffer or ping pong buffer? I don't understand what the last argument in pio_sm_config_xfer(pio, sm, PIO_DIR_TO_SM, BUF_SIZE, 1); does: different values doesn't seem to do anything -> any clues?

Dominant language
C
Stars
346
Forks
98
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/utils

All issues in raspberrypi/utils

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.