cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f0 TIM14 along with pwm to gpio without external trigger

Md Mubdiul Hasan
Associate III
Posted on October 14, 2016 at 04:23

Dear All,

I am trying to apply TIM14 along with pwm and put them to GPIO. The timer setting driver code is here,( one pulse mode has chosen) /* TIM14 init function */ static void MX_TIM14_Init(void) { TIM_IC_InitTypeDef sConfigIC; htimInstance = TIM14; htimInit.Prescaler = 0; htimInit.CounterMode = TIM_COUNTERMODE_UP; htimInit.Period = 0; htimInit.ClockDivision = TIM_CLOCKDIVISION_DIV1; if (HAL_TIM_Base_Init(&htim14) != HAL_OK) { Error_Handler(); } if (HAL_TIM_IC_Init(&htim14) != HAL_OK) { Error_Handler(); } if (HAL_TIM_OnePulse_Init(&htim14, TIM_OPMODE_SINGLE) != HAL_OK) { Error_Handler(); } sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING; sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; sConfigIC.ICFilter = 0; if (HAL_TIM_IC_ConfigChannel(&htim14, &sConfigIC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); } if (HAL_TIMEx_RemapConfig(&htim14, TIM_TIM14_MCO) != HAL_OK) { Error_Handler(); } } You can see here is 1 channel, after that can I initiate my PWM in this way? After calling PULSE variable, Configure the PWM channels #########################################*/ /* Common configuration for all channels */ sConfig.OCMode = TIM_OCMODE_PWM1; sConfig.OCPolarity = TIM_OCPOLARITY_HIGH; sConfig.OCFastMode = TIM_OCFAST_DISABLE; sConfig.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfig.OCIdleState = TIM_OCIDLESTATE_RESET; sConfig.OCNIdleState = TIM_OCNIDLESTATE_RESET; /* Set the pulse value for channel 1 */ sConfig.Pulse = PULSE1_VALUE; if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK) { /* Configuration Error */ Error_Handler(); } How about adding this thing from example? Start PWM signals generation #######################################*/ /* Start channel 1 */ if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK) { /* PWM Generation Error */ Error_Handler(); } Now how can I use this pwm to GPIO ? From document UM1785, peripheral Control function gives thisAPI, HAL_TIMEx_RemapConfig(&htim14, TIM_TIM14_MCO) How I can useCallback function? People use

HAL_TIM_MspPostInit to use GPIO.I have no way because, my circuit does not connect with TIM2/3.

STM32Cube_FW_F0_V1.6.0\Projects\STM32F070RB-Nucleo\Examples\TIM\TIM_PWMInput\Src andSTM32Cube_FW_F0_V1.6.0\Projects\STM32F070RB-Nucleo\Examples\TIM\TIM_InputCapture\Src Those examples are using TIM1/2! Kindly, help me please. #output-compare #pwm #timer-synchronisation
0 REPLIES 0