1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 08:36:14 +01:00

Portenta_H7_TimerInterrupt compiles in, but crash

This commit is contained in:
travis-farmer 2023-10-21 11:55:21 -04:00
parent a84eba7ab6
commit e816ef2b03
2 changed files with 35 additions and 5 deletions

View File

@ -32,7 +32,7 @@
#include "DCCTimer.h" #include "DCCTimer.h"
#include "DIAG.h" #include "DIAG.h"
#include "Portenta_H7_TimerInterrupt.h"
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
// Experimental code for High Accuracy (HA) DCC Signal mode // Experimental code for High Accuracy (HA) DCC Signal mode
// Warning - use of TIM2 and TIM3 can affect the use of analogWrite() function on certain pins, // Warning - use of TIM2 and TIM3 can affect the use of analogWrite() function on certain pins,
@ -194,11 +194,41 @@ void DCCTimer::reset() {
while(true){} while(true){}
}*/ }*/
INTERRUPT_CALLBACK interruptHandler=0; INTERRUPT_CALLBACK interruptHandler=0;
#ifndef DCC_EX_TIMER
#if defined(TIM6)
#define DCC_EX_TIMER TIM6
#elif defined(TIM7)
#define DCC_EX_TIMER TIM7
#elif defined(TIM11)
#define DCC_EX_TIMER TIM11
#else
#warning This STM32F4XX variant does not have Timers 6,7 or 11!!
#endif
#endif // ifndef DCC_EX_TIMER
HardwareTimer* _hwTimer = NULL;
void DCCTimer_Handler() __attribute__((interrupt));
void DCCTimer_Handler() {
interruptHandler();
}
void DCCTimer::begin(INTERRUPT_CALLBACK callback) { void DCCTimer::begin(INTERRUPT_CALLBACK callback) {
interruptHandler=callback; interruptHandler=callback;
noInterrupts(); noInterrupts();
// Init timer TIM15
Portenta_H7_Timer ITimer0(TIM15);
// Init timer TIM16
Portenta_H7_Timer ITimer1(TIM16);
_hwTimer->pause();
_hwTimer->setPrescaleFactor(1);
// timer.setOverflow(CLOCK_CYCLES * 2);
_hwTimer->setOverflow(DCC_SIGNAL_TIME, MICROSEC_FORMAT);
// dcctimer.attachInterrupt(Timer11_Handler);
_hwTimer->attachInterrupt(DCCTimer_Handler);
_hwTimer->setInterruptPriority(0, 0); // Set highest preemptive priority!
_hwTimer->refresh();
_hwTimer->resume();
interrupts(); interrupts();
} }
@ -277,11 +307,11 @@ int ADCee::read(uint8_t pin, bool fromISR) {
/* /*
* Scan function that is called from interrupt * Scan function that is called from interrupt
*/ */
#pragma GCC push_options //#pragma GCC push_options
#pragma GCC optimize ("-O3") //#pragma GCC optimize ("-O3")
void ADCee::scan() { void ADCee::scan() {
} }
#pragma GCC pop_options //#pragma GCC pop_options
void ADCee::begin() { void ADCee::begin() {
noInterrupts(); noInterrupts();

View File

@ -157,7 +157,7 @@
//#endif //#endif
#define SDA I2C_SDA #define SDA I2C_SDA
#define SCL I2C_SCL #define SCL I2C_SCL
#define DCC_EX_TIMER
// these don't work... // these don't work...
//extern const uint16_t PROGMEM port_to_input_PGM[]; //extern const uint16_t PROGMEM port_to_input_PGM[];
//extern const uint16_t PROGMEM port_to_output_PGM[]; //extern const uint16_t PROGMEM port_to_output_PGM[];