-
Notifications
You must be signed in to change notification settings - Fork 222
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
UART DMA #535
UART DMA #535
Conversation
Now it's not even doing as well as before - it either sends nothing or gibberish. |
Okay, the swapped dreq is what was causing the failures. |
Yep, while this code works we're definitely hitting some DMA issues with it. |
The existing code called reset_bringup() on split, which worked from a hard-reset but failed on a soft reset (eg - reset via debugger). Added a reset_bring_down call before reset_bringup to ensure that DMA is in a sensible state before using it.
We weren't resetting the DMA peripheral during init. |
IIRC probe-run doesn't reset the device after flashing, it just jumps to the entry point. This may be a bug in probe-run. |
All the other peripherals were already doing
on startup to ensure they're in a good state. DMA and PLL are presently the only things that only do
|
Just a side note: I wonder if we need a way to skip this reset. After all, the watchdog can be configured to not reset the whole chip but only parts of it. There are probably applications where you'd want to keep some peripherals running when the watchdog fires. For now, I'd prefer to keep things consistent and reset all peripherals on initialization. (PLL might be tricky - is it possible to get to that point while some clocks are already configured to run from PLL?) |
The C SDK and examples do not reset most of the peripherals, which suggests that this should be possible. |
rp2040-hal/src/dma/mod.rs
Outdated
@@ -238,7 +240,7 @@ impl<B: WriteBuffer> WriteTarget for B { | |||
/// transfers involving peripherals commonly have to wait for data to be available or for available | |||
/// space in write queues. This type defines whether the sink or the source shall pace the transfer | |||
/// for peripheral-to-peripheral transfers. | |||
#[derive(Clone, Copy)] | |||
#[derive(Clone, Copy, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd likely also be nice to have it derive defmt when available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should probably add more derives than that to the public-facing types too. Nice catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this and the DMAError struct to use
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
0e1c4e5
to
81ff1f3
Compare
Add DMA support for UART peripheral.
Tested with basic loopback example - works fine for single characters but explodes if you send many at once (you can reproduce this by holding a key, so it's not even that fast)