stm32: microsecond timer: set correct period value (#4567)
Driver sets (period - 1) to ARR (auto-reload register) So we need to set period to (1 << 32) to get maximum 0xffffffff value in ARR. But period is uint32_t. So set it to 0 and it will ovelap to UINT32_MAX at pwmp->tim->ARR = pwmp->period - 1;
This commit is contained in:
parent
5c8d44eec7
commit
8ff49301e5
|
@ -33,17 +33,24 @@ static void hwTimerCallback(PWMDriver*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr PWMConfig timerConfig = {
|
static constexpr PWMConfig timerConfig = {
|
||||||
SCHEDULER_TIMER_FREQ,
|
.frequency = SCHEDULER_TIMER_FREQ,
|
||||||
UINT32_MAX, // timer period = 2^32 counts
|
/* wanted timer period = 2^32 counts,
|
||||||
nullptr, // No update callback
|
* but driver set (period - 1) value to register
|
||||||
{
|
* also period is uint32_t
|
||||||
|
* So set it to zero so it will overlap to 0xffffffff when writen to register */
|
||||||
|
.period = 0,
|
||||||
|
.callback = nullptr, // No update callback
|
||||||
|
.channels = {
|
||||||
{PWM_OUTPUT_DISABLED, hwTimerCallback}, // Channel 0 = timer callback, others unused
|
{PWM_OUTPUT_DISABLED, hwTimerCallback}, // Channel 0 = timer callback, others unused
|
||||||
{PWM_OUTPUT_DISABLED, nullptr},
|
{PWM_OUTPUT_DISABLED, nullptr},
|
||||||
{PWM_OUTPUT_DISABLED, nullptr},
|
{PWM_OUTPUT_DISABLED, nullptr},
|
||||||
{PWM_OUTPUT_DISABLED, nullptr}
|
{PWM_OUTPUT_DISABLED, nullptr}
|
||||||
},
|
},
|
||||||
0, // CR1
|
.cr2 = 0,
|
||||||
0 // CR2
|
#if STM32_PWM_USE_ADVANCED
|
||||||
|
.bdtr = 0,
|
||||||
|
#endif
|
||||||
|
.dier = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
void portInitMicrosecondTimer() {
|
void portInitMicrosecondTimer() {
|
||||||
|
|
Loading…
Reference in New Issue