mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Merged in mindnever/librepilot/LP-463-Fix_Incorrect_timer_prescaler (pull request #374)
LP-463 Use correct timer clock for F1 target. All timers get 72M clock regardless of APB domain they live on.
This commit is contained in:
commit
246706ac9d
@ -261,26 +261,23 @@ void PIOS_Servo_SetHz(const uint16_t *speeds, const uint32_t *clock, uint8_t ban
|
||||
new_clock = clock[i];
|
||||
}
|
||||
|
||||
uint32_t apb_clock;
|
||||
uint32_t timer_clock;
|
||||
|
||||
// Choose the correct prescaler value for the APB the timer is attached
|
||||
|
||||
#if defined(STM32F10X_MD)
|
||||
if (timer == TIM1 || timer == TIM8) {
|
||||
apb_clock = PIOS_PERIPHERAL_APB2_CLOCK;
|
||||
} else {
|
||||
apb_clock = PIOS_PERIPHERAL_APB1_CLOCK;
|
||||
}
|
||||
// F1 has both timer clock domains running at master clock speed
|
||||
timer_clock = PIOS_MASTER_CLOCK;
|
||||
#elif defined(STM32F40_41xxx) || defined(STM32F446xx) || defined(STM32F411xE)
|
||||
if (timer == TIM1 || timer == TIM8 || timer == TIM9 || timer == TIM10 || timer == TIM11) {
|
||||
apb_clock = PIOS_PERIPHERAL_APB2_CLOCK;
|
||||
timer_clock = PIOS_PERIPHERAL_APB2_CLOCK;
|
||||
} else {
|
||||
apb_clock = PIOS_PERIPHERAL_APB1_CLOCK;
|
||||
timer_clock = PIOS_PERIPHERAL_APB1_CLOCK;
|
||||
}
|
||||
#else
|
||||
#error Unsupported MCU
|
||||
#endif
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (apb_clock / new_clock) - 1;
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (timer_clock / new_clock) - 1;
|
||||
TIM_TimeBaseStructure.TIM_Period = ((new_clock / speeds[i]) - 1);
|
||||
TIM_TimeBaseInit((TIM_TypeDef *)timer, &TIM_TimeBaseStructure);
|
||||
}
|
||||
|
@ -88,8 +88,6 @@
|
||||
// System Settings
|
||||
// -------------------------
|
||||
#define PIOS_MASTER_CLOCK 72000000
|
||||
#define PIOS_PERIPHERAL_APB1_CLOCK (PIOS_MASTER_CLOCK / 2)
|
||||
#define PIOS_PERIPHERAL_APB2_CLOCK (PIOS_MASTER_CLOCK / 1)
|
||||
|
||||
// -------------------------
|
||||
// Interrupt Priorities
|
||||
|
@ -139,8 +139,6 @@
|
||||
// System Settings
|
||||
// -------------------------
|
||||
#define PIOS_MASTER_CLOCK 72000000
|
||||
#define PIOS_PERIPHERAL_APB1_CLOCK (PIOS_MASTER_CLOCK / 2)
|
||||
#define PIOS_PERIPHERAL_APB2_CLOCK (PIOS_MASTER_CLOCK / 1)
|
||||
|
||||
// -------------------------
|
||||
// Interrupt Priorities
|
||||
|
Loading…
x
Reference in New Issue
Block a user