I am trying to generate a clock of 1.4MHz using the STM32F103C8Tx using the STM32CubeMX.
First of all, in my code I have pin PB13 as output and in main I toggle it every one second. 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 28MHz.
TIM3 Channel2 :PWM Generation CH2
Internal Clock
Timer3 :
Here is the code :
https://gist.github.com/icamaster/e45649478a2e01d5beb46f4313e79e9cApart from the generate part, I have added these lines before the while(1) in the main :
HAL_TIM_PWM_MspInit(&htim3);
HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_2);
Where the *_MspInit function is :
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
{
if(htim_pwm->Instance==TIM3)
{
/* USER CODE BEGIN TIM3_MspInit 0 */
/* USER CODE END TIM3_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM3_CLK_ENABLE();
/* USER CODE BEGIN TIM3_MspInit 1 */
/* USER CODE END TIM3_MspInit 1 */
}
}
The LED is blinking at the set interval but I have no output on the pin A7 (Timer3 channel 2). This is verified on the oscilloscope.