cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use multi GPIOs based on one common PWM channel?

Micha Valach
Associate III

In my project I uses 2 LEDs and one Buzzer, all of them based on PWM control

My current HW implementation is as follow:

  1. Led#1 connected to PA.3 - PWM based on TIM2/CH4
  2. Led#2 connected to PB.9 - PWM based on TIM1/CH3N
  3. Buzzer connected to PA.0 - PWM based on TIM2/CH1

LED#1 and LED#2 should work at almost the same Freq. and the best for my needs is: 400Hz

and Buzzer optimal Freq. is: 4KHz

I set TIM1 Freq. to be 400Hz (CLK=64M, PSC=3 and Period=53333) - - and it works fine as expected!

I set TIM2 Freq. to be 4KHz with CH1 Duty Cycle: 50% - and it works fine as expected!

However this mean that LED#1on TIM2/CH4 must work at the same Buzzer Freq: 4KHz and NOT at 400Hz similar to LED#2

My Question are:

  1. In current HW setup is it possible to solve above issue, and make LED#1 & LED#2 to both work at 400Hz?
  2. Is there a GPIO solution, to activate both LED#1 (PA.3) and LED#2 (PB.9) from one common PWM channel (example:PB.9) ?

P.S. I also tried to make it using TIM2 interrupt, but this is involved with TIM Interrupt every 50-100uSec interval which cause performance degradation

Best Regards,

Micha

2 REPLIES 2
  1. no
  2. not directly. You can trigger DMA from TIM1, outputting data to GPIOA.

What's wrong with driving a LED's PWM at 4kHz?

JW

Micha Valach
Associate III

Hi Jan,

Thank you for your prompt reply, I'll give a try

As for your concern about driving a LED's PWM at 4kHz, It work fine for the LED, however this 4KHz freq. generate some digital noise for my RF Antenna,

HW Eng. check manually and found out that Freq. about ~400Hz will NOT effect the RF Antenna

Best Regards,

Micha