2019-05-28 09:04 AM
I've my LCD backlight control on STM32F429 pin PB4, and as a digital output it was fine. I chose this pin because it can be configured as a PWM output.
I've set up TIM3 Ch1 in CubeMX. I just want a free-running PWM with a dynamically configurable duty cycle, so I can set my backlight to 'bright', 'medium' or 'dim' settings.
I'm getting no signal on PB4, it is just sitting high.
Did I miss something? Is there an 'enable' or 'start' instruction I need to add?
Solved! Go to Solution.
2019-05-29 02:18 AM
OK, I now have PWM on PB4, thanks to Uncle Google and this page
I needed to add
HAL_TIM_Base_Start(&htim3);
HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_1);
Microchip's Code Configurator tool gives you a header listing all the functions to initialise, start, stop and control your configured peripheral, why can't CubeMX be as helpful?
2019-05-28 10:32 AM
Activate the gpio alternate function, configure the timer channel and activate the channel in the timer. Go debug mode, view gpio and timer registers, manually inspect and tweak until things get better, then fix the sw. LED dimming is similar. Remember that yout eye perceive the log so don t do a linear duty cycle.... You will need more steps than you think....
2019-05-28 11:25 AM
The pin is set to the alternate function, timer output. I'd assumed CubeMX would set things up ready to roll.
I've driven the backlight from a sig generator so have a good idea of requirements.
2019-05-28 12:05 PM
Read out and check/post content of timer and relevant GPIO registers.
JW
2019-05-29 12:40 AM
2019-05-29 12:40 AM
2019-05-29 12:41 AM
If this were a PIC micro, I'd go through the registers bit by bit, but here there are too many and descriptions are cryptic. In any case, isn't that why I'm using CubeMX?
2019-05-29 01:11 AM
OK, I've manually the TIM3_CR1 "CEN" bit, and now I can see the CNT register incrementing between breakpoiints. Still no activity on the PB4 pin assigned to TIM3 Ch1.
2019-05-29 01:53 AM
How do I find the AFIO_MAPR register in the debug SFR listing, so I can check the alternate function mapping?
2019-05-29 02:18 AM
OK, I now have PWM on PB4, thanks to Uncle Google and this page
I needed to add
HAL_TIM_Base_Start(&htim3);
HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_1);
Microchip's Code Configurator tool gives you a header listing all the functions to initialise, start, stop and control your configured peripheral, why can't CubeMX be as helpful?