I am trying to generate a clock of 1.4 MHz using the STM32F103C8Tx using STM32CubeMX.
First of all, in my code I have pin PB13 as output and in main I toggle it every two seconds. This works.
Now the more important part. Things I have set up in CubeMX:
- I have set up the base clock of the device to 28 MHz.
- TIM3 Channel2:
Output compare CH2PWM Generation CH2 - Internal Clock
- Timer3:
I have compiled the generated code in the IDE from OpenSTM32 and uploaded it. The LED is blinking at the set interval, but I have no output on the pin B5 A7 (Timer3 channel 2). This is verified on the oscilloscope.
Code(main):
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_TIM3_Init();
//These two lines were manually added
HAL_TIM_Base_Start(&htim3);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
while (1)
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(5000);
}
}
The rest can be found here.
HAL_TIM_Base_Start(&htim3);
line was not needed (I don't think it hurt either). \$\endgroup\$