Various fixes for DUE... (#10152)
- Watchdog reset during SD Card initialization. - Move `DebugMonitor` to `DebugMonitor_Due.cpp`. - Since the watchdog is enabled on boot do extra resets during init. - Have `thermalManager` do watchdog reset before its ISR starts to prevent reset. - Ensure that timers are stopped before reprogramming them to address tone issues. - Improve SAM3XE reset when reflashed through the native port.
This commit is contained in:
committed by
Scott Lahteine
parent
c3c264978f
commit
97e8a6ebd9
@ -96,6 +96,15 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;
|
||||
uint32_t channel = TimerConfig[timer_num].channel;
|
||||
|
||||
// Disable interrupt, just in case it was already enabled
|
||||
NVIC_DisableIRQ(irq);
|
||||
|
||||
// Disable timer interrupt
|
||||
tc->TC_CHANNEL[channel].TC_IDR = TC_IDR_CPCS;
|
||||
|
||||
// Stop timer, just in case, to be able to reconfigure it
|
||||
TC_Stop(tc, channel);
|
||||
|
||||
pmc_set_writeprotect(false);
|
||||
pmc_enable_periph_clk((uint32_t)irq);
|
||||
NVIC_SetPriority(irq, TimerConfig [timer_num].priority);
|
||||
@ -103,12 +112,16 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
// wave mode, reset counter on match with RC,
|
||||
TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1);
|
||||
|
||||
// Set compare value
|
||||
TC_SetRC(tc, channel, VARIANT_MCK / 2 / frequency);
|
||||
|
||||
// And start timer
|
||||
TC_Start(tc, channel);
|
||||
|
||||
// enable interrupt on RC compare
|
||||
tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPCS;
|
||||
|
||||
// Finally, enable IRQ
|
||||
NVIC_EnableIRQ(irq);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user