![Neutral :|](./images/smilies/icon_neutral.gif)
I am trying to get 2 PWM output . the following code is working fine but how to get second PWM on PB1 pin .
how modify following line for 2 Pwm or Timer or Counter .
HardwareTimer *MyTim = new HardwareTimer(Instance);
How to change the *MyTim & instance incase of 2nd Timer or PWM or Counter has to work
Code: Select all
#define pin PA0
void setup()
{
// no need to configure pin, it will be done by HardwareTimer configuration
// pinMode(pin, OUTPUT);
// Automatically retrieve TIM instance and channel associated to pin
// This is used to be compatible with all STM32 series automatically.
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);
// Configure and start PWM
// MyTim->setPWM(channel, pin, 5, 10, NULL, NULL); // No callback required, we can simplify the function call
MyTim->setPWM(channel, pin, 5, 10); // 5 Hertz, 10% dutycycle
}
void loop()
{
/* Nothing to do all is done by hardware. Even no interrupt required. */
}