2019-11-17 12:19 PM
Hi,
I am using STM32 F303 VCT6 and want to output PWM signal on TIM3, TIM2.
I followed the instructions in some video to build the code using STM32CubeMX.
I set the Clock Source for both timers to 'Internal Clock'.
I set all four channels for bother timers to 'PWM Generation Chx'
I set the Parameter Settings as follows:
Prescaler: 16
Counter Period (AutoReload Register): 100
Pulse: different values to each channel from 25 to 100
I created the project and then started the timers:
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1); // for each channel and for both timers.
The question is, what is still missing? I dont get any output on the timers????
2019-11-17 12:21 PM
2019-11-17 12:44 PM
You may perhaps also need to set the respective pins in GPIO: in MODER, set respective bits to AF for given pins, and in AFR[] set the respective AF.
If in doubts, read out the respective timers and GPIO registers' content and check.
I don't Cube.
JW
PS. Please change your username to a normal nick.
2019-11-17 01:21 PM
Thanks for the reply.
As I am beginner here, can you please write more details?
2019-11-17 01:29 PM
Am I really using GPIO? I am using only the timer, and I can identify the pins for each timer/channel on the board, and I am connecting my external LEDs to those pins.
Is this not enough?
2019-11-17 02:13 PM
All pins are controlled by the GPIO module. In that, you have to set the pin's mode, and if the mode is not a plain input or output or analog, you set it as "Alternate Function", and then you have to chose which particular alternate function for that pin you want to use (see the pin assignment table in the datasheet for your STM32).
Read the GPIO chapter in the Reference Manual (RM) for your STM32.
JW
2019-11-17 02:55 PM
I see in the datasheet that the PIN2 PE2 has three alternate functions:
TRACECK, TIM3_CH1, G7_IO1.
Does this mean that I should explicitly set the alternate function TIM3_CH1 as active?
According to the RM, the registers GPIOx_AFRL , GPIOx_AFRH are responsible for changing alternate functions, but how can write in those registers? Which function should I call for this purpose? (Knowing that I am using HAL).
Sorry for my primitive questions
Regards