So why this line was removed in the example?fredbox wrote: ↑Tue Jan 14, 2020 10:28 pmas the first timerBase line.Code: Select all
timerBase->setMode(2, TIMER_OUTPUT_COMPARE);
https://github.com/stm32duino/STM32Exam ... 0a3352f716
So why this line was removed in the example?fredbox wrote: ↑Tue Jan 14, 2020 10:28 pmas the first timerBase line.Code: Select all
timerBase->setMode(2, TIMER_OUTPUT_COMPARE);
You're right, but I see nothing but the master branch on STM32Example repo.fpiSTM wrote: ↑Wed Jan 15, 2020 7:54 am It is required for v1.8.0 of the core.
It will not be needed for higher version.
I guess you use the STM32Examples master not the last official release which does not contains this update.
In a general way you have to use the release version of the archive.
Else if you have to use the repo master, you have to use it for all (core, libraries,...)
Code: Select all
#define LED_RED 1 // was already defined elsewhere
void setup()
{
pinMode(LED_RED, OUTPUT);
digitalWrite(LED_RED, HIGH);
TIM_TypeDef *Instance = TIM1;
//TIM_TypeDef *Instance = TIM2;
//TIM_TypeDef *Instance = TIM3;
HardwareTimer *timerBase = new HardwareTimer(Instance);
timerBase->setMode(1, TIMER_OUTPUT_COMPARE, NC);
//timerBase->setMode(1, TIMER_OUTPUT_COMPARE);
//timerBase->setMode(2, TIMER_OUTPUT_COMPARE);
timerBase->setOverflow(5, HERTZ_FORMAT);
timerBase->attachInterrupt(timer_callback);
timerBase->resume();
}
void loop()
{
}
void timer_callback(HardwareTimer *)
{
digitalWrite(LED_RED, !digitalRead(LED_RED));
}