From 365329cd540f631f1cfe805b475f792cf00257e0 Mon Sep 17 00:00:00 2001 From: Yuuki NAGAO Date: Sun, 27 Jul 2025 22:03:42 +0900 Subject: [PATCH] stm32/dac: Fix DAC write for MCUs that have D-Cache. To prevent wrong DAC output, clean D-cache before starting DMA. For more details, please refer to the following document: https://www.st.com/resource/en/application_note/DM00272913.pdf Signed-off-by: Yuuki NAGAO --- ports/stm32/dac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/stm32/dac.c b/ports/stm32/dac.c index 040892553d..8022fd274c 100644 --- a/ports/stm32/dac.c +++ b/ports/stm32/dac.c @@ -485,6 +485,9 @@ mp_obj_t pyb_dac_write_timed(size_t n_args, const mp_obj_t *pos_args, mp_map_t * #endif } + // To prevent invalid dac output, clean D-cache before starting dma. + MP_HAL_CLEAN_DCACHE(bufinfo.buf, bufinfo.len); + uint32_t align; if (self->bits == 8) { align = DAC_ALIGN_8B_R;