Skip to content

Commit 8be148c

Browse files
committed
fix(h5): disable cache during DAC channel configuration
Fixes #2508 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 56655f3 commit 8be148c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: libraries/SrcWrapper/src/stm32/analog.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,28 @@ void dac_write_value(PinName pin, uint32_t value, uint8_t do_init)
418418
dacChannelConf.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE;
419419
#endif
420420
/*##-2- Configure DAC channel1 #############################################*/
421+
#if defined(STM32H5xx) && !defined(TIM8) && !defined(HAL_ICACHE_MODULE_DISABLED)
422+
bool icache_enabled = false;
423+
if (HAL_ICACHE_IsEnabled() == 1) {
424+
icache_enabled = true;
425+
/* Disable instruction cache prior to internal cacheable memory update */
426+
if (HAL_ICACHE_Disable() != HAL_OK) {
427+
Error_Handler();
428+
}
429+
}
430+
#endif /* STM32H5xx && !defined(TIM8) &&!HAL_ICACHE_MODULE_DISABLED */
421431
if (HAL_DAC_ConfigChannel(&DacHandle, &dacChannelConf, dacChannel) != HAL_OK) {
422432
/* Channel configuration Error */
423433
return;
424434
}
435+
#if defined(STM32H5xx) && !defined(TIM8) && !defined(HAL_ICACHE_MODULE_DISABLED)
436+
if (icache_enabled) {
437+
/* Re-enable instruction cache */
438+
if (HAL_ICACHE_Enable() != HAL_OK) {
439+
Error_Handler();
440+
}
441+
}
442+
#endif /* STM32H5xx && !defined(TIM8) && !HAL_ICACHE_MODULE_DISABLED */
425443
}
426444

427445
/*##-3- Set DAC Channel1 DHR register ######################################*/

0 commit comments

Comments
 (0)