Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years ago.
Locked AntiPhase PWM
Hello,
I would like to implement following Locked Antiphase (hope this is the right name for it) PWM, which will invert 2 PWM signals with regard to each other. Those signals are then meant to be fed to an H-bridge IC. How is it possible to implement it with mbed LPC1768?
1 Answer
6 years ago.
Generating these signals needs to be done directly with the timer hardware. First step is to ensure the timers on that micro support the configuration you need. You are going to have to bust out the reference manual. You are going to want adjustable deadtime as well to prevent shoot through during the transition.
Mbed default libraries are not going to support this. You might get lucky and find a library someone has created. But most likely to make this happen you will need to dig in and go right down and interact with the timer registers. Source code for pwm output is here.
https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_NXP/TARGET_LPC176X/pwmout_api.c
Manual here:
https://www.nxp.com/docs/en/user-guide/UM10360.pdf
At first glance it looks like it might not be too bad using the PWM1 module which has multiple output channels. And the code has already setup one channel for you. You can see the code loads the duty cycle value into the Match register (MR) as described in manual section 24.4. You'll have to figure out how to setup one of the other PWM1 output channels and do some math to get the right MR values for that channel. Second pwm channel will require 2 match values since it needs to be offset from timer 0 point both rising and falling.