DSB instruction for implementing delay after an RCC peripheral clock enabling
Hi,
I'm new to STM32 microcontrollers, specifically STM32G070RB which is an Arm Cortex M0+ MCU.
From section 5.2.16 (page# 134) of https://www.st.com/resource/en/reference_manual/rm0454-stm32g0x0-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
Peripheral clock enable registers
Caution: The enable bit has a synchronization mechanism to create a glitch-free clock for the peripheral.
After the enable bit is set, there is a 2-clock-cycle delay before the clock be active, which the software must take into account.As per https://www.st.com/resource/en/errata_sheet/dm00037591-stm32f405-407xx-and-stm32f415-417xx-device-limitations-stmicroelectronics.pdf Section 2.2.13 Delay after an RCC peripheral clock enabling, 3 workarounds are mentioned.
• Use the DSB instruction to stall the Arm® Cortex®-M4 CPU pipeline until the instruction has completed.
• Insert “n” NOPs between the RCC enable bit write and the peripheral register writes (n = 2 for AHB
peripherals, n = 1 + AHB/APB prescaler for APB peripherals).
• Simply insert a dummy read operation from the corresponding register just after enabling the peripheral
clock.
I hope these workarounds are applicable for STM32G070RB also.
I'm planning to use the DSB instruction after enabling the peripheral clock.
void enable_gpioa_clock(void)
{
RCC_IOPENR |= (0x1U << 0x0U);
__asm volatile("DSB");
}
Are there any drawbacks in using DSB instruction here?
Thanks in advance.
