From 170c4720df4722fa31fb5927ec624a1e6754746f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 3 Sep 2024 10:41:38 +0200 Subject: [PATCH] fix(h5): disable cache during DAC channel configuration Fixes #2508 Signed-off-by: Frederic Pillon --- libraries/SrcWrapper/src/stm32/analog.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libraries/SrcWrapper/src/stm32/analog.cpp b/libraries/SrcWrapper/src/stm32/analog.cpp index 58b8f809cc..538e1bee77 100644 --- a/libraries/SrcWrapper/src/stm32/analog.cpp +++ b/libraries/SrcWrapper/src/stm32/analog.cpp @@ -418,10 +418,28 @@ void dac_write_value(PinName pin, uint32_t value, uint8_t do_init) dacChannelConf.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE; #endif /*##-2- Configure DAC channel1 #############################################*/ +#if defined(STM32H5xx) && !defined(TIM8) && !defined(HAL_ICACHE_MODULE_DISABLED) + bool icache_enabled = false; + if (HAL_ICACHE_IsEnabled() == 1) { + icache_enabled = true; + /* Disable instruction cache prior to internal cacheable memory update */ + if (HAL_ICACHE_Disable() != HAL_OK) { + Error_Handler(); + } + } +#endif /* STM32H5xx && !defined(TIM8) &&!HAL_ICACHE_MODULE_DISABLED */ if (HAL_DAC_ConfigChannel(&DacHandle, &dacChannelConf, dacChannel) != HAL_OK) { /* Channel configuration Error */ return; } +#if defined(STM32H5xx) && !defined(TIM8) && !defined(HAL_ICACHE_MODULE_DISABLED) + if (icache_enabled) { + /* Re-enable instruction cache */ + if (HAL_ICACHE_Enable() != HAL_OK) { + Error_Handler(); + } + } +#endif /* STM32H5xx && !defined(TIM8) && !HAL_ICACHE_MODULE_DISABLED */ } /*##-3- Set DAC Channel1 DHR register ######################################*/ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy