-
Notifications
You must be signed in to change notification settings - Fork 208
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
100% Duty cycle is not completely 100% (see picture) #48
Comments
Some hardware simply isn't capable of 100% duty cycle. Typically those boards give a very short pulse, less than 1 timer cycle. Or it could be a software bug. Which board are you using? I can't tell from your text and photo. |
Here is the other code I run on my Arduino Uno (same hardware as before): source
|
While this isn't an issue in my project, I did observe it on an Arduino Nano clone board (Atmega328p). |
@PaulStoffregen what do you think about that? //****************************
// PWM outputs
//****************************
void setPwmDuty(char pin, unsigned int duty) __attribute__((always_inline)) {
unsigned long dutyCycle = pwmPeriod;
dutyCycle *= duty;
dutyCycle >>= 10;
if (pin == TIMER1_A_PIN) {
FTM1_C0V = dutyCycle;
} else if (pin == TIMER1_B_PIN) {
FTM1_C1V = dutyCycle;
}
}
When we do the operation of ">>= 10" we divide by 2^10 so divide by 1024. I think we will never get 100% when we provide 1023 as max duty cycle. Anyway I think that the code for AVR id good, just the documentation needs to be updated. |
here are part of the code I am using:
The text was updated successfully, but these errors were encountered: