2023-08-16 02:07 AM
Hello,
I have a question regarding the peripheral reset registers.
For the G070 device, in the RM0454, section 5.2.16, it is specified that the clock enable of a peripheral takes 2 cycles to prevent glitches. Fine.
However, how do you experts use the reset registers ? Let's say that you want to reset the CRC peripheral.
I'm doing it like so for the moment:
RCC->AHBENR |= RCC_AHBENR_CRCEN; // Turn ON CRC peripheral clock
delay_us(5);
RCC->AHBRSTR = RCC_AHBRSTR_CRCRST; // Reset peripheral
delay_us(5);
RCC->AHBRSTR = 0;
delay_us(5);
But I don't know if any delays are indeed needed or not here. Any thought on this ?
Best regards,
Kraal
2023-08-16 05:15 AM
There's no need to use the reset registers on an initial powerup as the registers will all be at their initial values.
2023-08-16 06:24 AM
Thanks but that is not an answer to the question. If you jump from a bootloader to an application you might want to reset an already configured and used peripheral to its reset state.
2023-08-16 07:09 AM
This is an interesting topic. See these threads for example:
https://community.st.com/t5/stm32-mcu-products/inline-assembly-macro-inconsistent/m-p/580743#M220384
Bottom line: unless very restricted in time, delay for a *few* clocks. Use a reliable method for the delay.