[NUCLEO_F401RE] Add missing IT flag reset + update system clock variable

pull/342/head
bcostm 2014-06-09 12:51:24 +02:00
parent 18cade6354
commit a0d3da9a36
2 changed files with 4 additions and 0 deletions

View File

@ -42,6 +42,7 @@ void us_ticker_irq_handler(void);
void timer_irq_handler(void) {
// Channel 1 for mbed timeout
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
us_ticker_irq_handler();
}

View File

@ -238,6 +238,9 @@ void pwmout_period_us(pwmout_t* obj, int us) {
__HAL_TIM_DISABLE(&TimHandle);
// Update the SystemCoreClock variable
SystemCoreClockUpdate();
TimHandle.Init.Period = us - 1;
TimHandle.Init.Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
TimHandle.Init.ClockDivision = 0;