HardwareTimer library (examples) do not work

Working libraries, libraries being ported and related hardware
Post Reply
jojos998
Posts: 1
Joined: Sun Mar 08, 2020 8:31 am

HardwareTimer library (examples) do not work

Post by jojos998 »

Hello!

I am trying to use HardwareTimer library which is part of STM32's official core libraries. After following instructions on https://github.com/stm32duino/wiki/wiki ... er-library I was not able to use it.

I have copied the provided examples (Timebase_callback.ino and PWM_FullConfiguration.ino) and none of them works. Even putting flag into callback function

Code: Select all

void Update_IT_callback(HardwareTimer*)
and checking the flag in loop() indicates that callback function is never called by the timer.

I have STM32 Cores 1.8.0. instaled.

Any ideas what could be the reason?
User avatar
fpiSTM
Posts: 1754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: HardwareTimer library (examples) do not work

Post by fpiSTM »

Use the official released STM32Examples then example will work.
sale
Posts: 1
Joined: Thu May 14, 2020 12:22 pm

Re: HardwareTimer library (examples) do not work

Post by sale »

For me, the blue pill plate works try this
#define pin PB9
void setup()
{
Serial.begin(9600);
TIM_TypeDef *Instance = (TIM_TypeDef *)pinmap_peripheral(digitalPinToPinName(pin), PinMap_PWM);
uint32_t channel = STM_PIN_CHANNEL(pinmap_function(digitalPinToPinName(pin), PinMap_PWM));
// Instantiate HardwareTimer object. Thanks to 'new' instantiation, HardwareTimer is not destructed when setup() function is finished.
HardwareTimer *MyTim = new HardwareTimer(Instance );
// MyTim->setPWM(channel, pin, 5, 10, NULL, NULL); // No callback required, we can simplify the function call
MyTim->setPWM(channel, pin, 400, 10); // 400 Hertz, 10% dutycycle
}
void loop()
{
}
But I don't know how to call setPWM in loop. If anyone can help me with a simple example of how to call PWM in loop.
I want this
void loop{
MyTim->setPWM(channel, pin, 400, 10);
}
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: HardwareTimer library (examples) do not work

Post by stas2z »

Post Reply

Return to “Libraries & Hardware”