Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for STM32 timer output to be enabled before returning from enable procedure. #437

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liampwll
Copy link

RM0386 Rev 6 22.3.12 notes that there may be a delay before the BDTR.MOE bit reads as 1 after writing to it. The RM says that only a single instruction is needed, but testing has shown that this is incorrect.

With the previous code, calling Enable_Main_Output and then immediately calling a procedure to set a different part of the register could result in the MOE bit being inadvertently set low.

…e procedure.

RM0386 Rev 6 22.3.12 notes that there may be a delay before the BDTR.MOE
bit reads as 1 after writing to it. The RM says that only a single
instruction is needed, but testing has shown that this is incorrect.

With the previous code, calling Enable_Main_Output and then immediately
calling a procedure to set a different part of the register could result
in the MOE bit being inadvertently set low.
@CLAassistant
Copy link

CLAassistant commented Nov 17, 2024

CLA assistant check
All committers have signed the CLA.

@liampwll
Copy link
Author

The same also applies to BKE and BKP as noted by the previous paragraph in the reference manual:

When the BKEx and BKPx bits are written, a delay of 1 APB clock cycle is applied before the writing is effective. Consequently, it is necessary to wait 1 APB clock period to correctly read back the bit after the write operation.

It's very likely that this is causing issues in the following code in stm32-timers.adb, but I haven't tested this since we don't use it:

      This.BDTR.Automatic_Output_Enabled      := Automatic_Output_Enabled;
      This.BDTR.Break_Polarity                := Break_Polarity;
      This.BDTR.Break_Enable                  := Break_Enabled;
      This.BDTR.Off_State_Selection_Run_Mode  := Off_State_Selection_Run_Mode;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants