embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
5.66k stars 791 forks source link

Mitigate nrf52832 dma errata #460

Open jacobrosenthal opened 3 years ago

jacobrosenthal commented 3 years ago

https://infocenter.nordicsemi.com/pdf/nRF52_PAN_109_add_v1.1.pdf

plaes commented 1 year ago

Anomaly 109 - DMA access transfers might be corrupted Affects following peripherals on nrf52832:

Easiest workaround that would actually work for all peripherals (from section 3.7 from Anomaly 109 Addendum)


unsafe fn poke(addr: u32, val: u32) {
    (addr as *mut u32).write_volatile(val);
}

// Workaround for all peripherals:
// Turn on the 64 MHz clockdomain - increases CPU idle current by around 500 μA.
// Might not be usable in cases where power usage is constrained.

// Enable workaround
unsafe {
    poke(0x4006EC00, 0x00009375);
    poke(0x4006ED08, 0x00000003);
    poke(0x4006EC00, 0x00009375);
}
// Disable workaround
unsafe {
    poke(0x4006EC00, 0x00009375);
    poke(0x4006ED08, 0x00000000);
    poke(0x4006EC00, 0x00009375);
}
...