-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
PWM issue with TIMER2 #178
Comments
Thanks I will see is @martinayotte has time to test for me on his F4 hardware |
I tried this on my STM32F4 discovery board and can confirm the fix. Test code: int led = PA15;
int signalpin = PC11;
int brightness = 0;
void setup() {
pinMode(led, PWM);
gpio_set_af_mode(GPIOA, 15, 1); // we should probably do this in the pinMode code
pinMode(signalpin, OUTPUT);
}
void loop() {
digitalWrite(signalpin, HIGH);
analogWrite(led, brightness);
if(brightness == 0) {
brightness = 32768;
} else {
brightness = 0;
}
delay(1);
digitalWrite(signalpin, LOW);
delay(29);
} Before CH1/Yellow = PA15, CH2/Blue = PC11: After: The PWM output does eventually show up without the change. |
Thanks Dan I'll do a merge straight on Github Edit Oops I've realized this is not a PR. Can you or the OP do this as a PR ? |
Any chance of a PR for this ? |
Credit to hathach for finding and fixing this: rogerclarkmelbourne#178 Fixes rogerclarkmelbourne#178
Credit to hathach for finding and fixing this: rogerclarkmelbourne#178 Fixes rogerclarkmelbourne#178
Hi Roger, |
Board: Adafruit WICED Feather https://www.adafruit.com/product/3056
Issue: PWM with PA15 (Timer2 CH1) only start to work after 3-5 minutes.
Solution:
I have spent a few days to follow all the registers and dive into ST manuals to troubleshoot the issue. It turns out to be a very easy fix. As far as I know the EGR_UG bit must be set after setting the Preload to have preload value taking effect immediately. Otherwise, we will need to wait for 2-3 minutes before it starts to work !!!!!!!
Code : Moving Line 161
regs->EGR = TIMER_EGR_UG
to right above the timer resume L178.https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F4/cores/maple/boards.cpp#L161
The text was updated successfully, but these errors were encountered: