Skip to content

Commit

Permalink
RTC LSI calibration should clear pending interrupts before start
Browse files Browse the repository at this point in the history
  • Loading branch information
andysworkshop committed Aug 10, 2014
1 parent 1c4c92e commit 7964e8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/timer_interrupts/timer_interrupts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ class TimerInterruptsTest {
timer.setTimeBaseByFrequency(5000,4999,TIM_CounterMode_CenterAligned3);

/*
* Enable just the Update interrupt.
* Enable just the Update interrupt, clearing any spurious pending flag first
*/

timer.clearPendingInterruptsFlag(TIM_IT_Update);
timer.enableInterrupts(TIM_IT_Update);

/*
Expand Down
10 changes: 10 additions & 0 deletions lib/include/usart/features/f4/UsartInterruptFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace stm32plus {

void enableInterrupts(uint16_t interruptMask);
void disableInterrupts(uint16_t interruptMask);
void clearPendingInterruptsFlag(uint16_t interruptMask) const;
};


Expand Down Expand Up @@ -144,6 +145,15 @@ namespace stm32plus {
USART_ITConfig(_usart,interruptMask,DISABLE);
}

/**
* Clear the selected pending interrupt flags
* @param interruptMask The bitmask of interrupts, e.g. USART_IT_TC / USART_IT_RXNE
*/

template<uint8_t TUsartNumber>
inline void UsartInterruptFeature<TUsartNumber>::clearPendingInterruptsFlag(uint16_t interruptMask) const {
USART_ClearITPendingBit(_usart,interruptMask);
}

/**
* Enabler specialisation, Usart 1
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc/f0/RtcMeasuredLsiFrequencyProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace stm32plus {
// enable interrupts and the timer

timer14.Timer::enablePeripheral();
timer14.clearPendingInterruptsFlag(TIM_IT_CC1);
timer14.enableInterrupts(TIM_IT_CC1);

// wait until completed
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc/f4/RtcMeasuredLsiFrequencyProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace stm32plus {
// enable interrupts and the timer

timer5.Timer::enablePeripheral();
timer5.clearPendingInterruptsFlag(TIM_IT_CC4);
timer5.enableInterrupts(TIM_IT_CC4);

// wait until completed
Expand Down

0 comments on commit 7964e8b

Please sign in to comment.