Set PWM output range between VDD and GND
Posted: Fri Mar 21, 2014 6:01 pm
Hi,
I'm very new to embedded development in general and chibios in particular.
I need to write a program that activates 4 individually controlled PWM channels on external pins on an STM32F4Discovery development board.
I managed to get PWM up and running but am facing two problems.
1. My PWM output oscillates between +1.5v and -1.5, I am using a power FET to drive high current LEDs with the PWM signal for controlling their brightness but as the power FET requires 3V to fully switch on I need to make my PWM signal Oscillate between +3V and 0V. is there any simple way in which I can achieve that in software?
my output pins are currently set like so:
palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(2)); // Port PB8
palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(2)); //Port PB9
2. I need to switch on the LEDs only when an external pin goes high and I need the LEDs to switch back off (ie. PWM output gets switched off) when the signal on the external pin goes low. I believe that I need to enable an external interrupt on an external pin with a conditional statement for pwmDisableChannelI() and pwmEnableChannelI() but I could not find any examples on enabling a simple external interrupt.
any help would be greatly appreciated!
thank you
I'm very new to embedded development in general and chibios in particular.
I need to write a program that activates 4 individually controlled PWM channels on external pins on an STM32F4Discovery development board.
I managed to get PWM up and running but am facing two problems.
1. My PWM output oscillates between +1.5v and -1.5, I am using a power FET to drive high current LEDs with the PWM signal for controlling their brightness but as the power FET requires 3V to fully switch on I need to make my PWM signal Oscillate between +3V and 0V. is there any simple way in which I can achieve that in software?
my output pins are currently set like so:
palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(2)); // Port PB8
palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(2)); //Port PB9
2. I need to switch on the LEDs only when an external pin goes high and I need the LEDs to switch back off (ie. PWM output gets switched off) when the signal on the external pin goes low. I believe that I need to enable an external interrupt on an external pin with a conditional statement for pwmDisableChannelI() and pwmEnableChannelI() but I could not find any examples on enabling a simple external interrupt.
any help would be greatly appreciated!
thank you