Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not writing the full buffer every 9th time #43

Open
ksmarty opened this issue Jan 28, 2025 · 2 comments
Open

Not writing the full buffer every 9th time #43

ksmarty opened this issue Jan 28, 2025 · 2 comments

Comments

@ksmarty
Copy link

ksmarty commented Jan 28, 2025

Hello! I'm encountering a weird issue where I'm able to write 8 full buffers of 4080 bytes, but then only 84/128 bytes of the buffer are written.
It follows this pattern:

4080 x 8
84
4080 x 8
128
4080 x 8
128
...

I confirmed the buffer has a full 4080 bytes each time, and it's evident that data is missing when listening to the audio.

This is the main loop where the issue is happening:

  let mut data = [0u8; 4092];
  let mut transfer = i2s_rx.read_dma_circular_async(rx_buffer_i2s).unwrap();

  loop {
      let i2s_bytes_read = transfer.pop(&mut data).await.unwrap();

      let x = f.write(&data[..i2s_bytes_read]).await.unwrap();
      f.flush().await.unwrap();
      println!("{:?}", x);

      if button.is_low() {
          // Debounce
          button.wait_for_high().await;
          break;
      }
  }

You can find the full source code here: https://github.com/ksmarty/diane/blob/main/src/bin/async_main.rs

Please let me know any ideas you might have on why this is happening. Thanks!

@MabezDev
Copy link
Owner

Could you try and make the repro smaller? Ideally without any other peripherals in play, just SPI for the card.

@ksmarty
Copy link
Author

ksmarty commented Jan 28, 2025

https://github.com/ksmarty/diane/blob/repro/src/bin/async_main.rs

I've removed as much extra code as I could. I left the i2s microphone setup as I wasn't sure what to replace it with as a source of input data to fill the buffer. I can provide a schematic if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants