This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
If I want to generate and output a PWM signal based the comparison result of an analog input (input_A) and an internal value (input_B) , can I use Action-Qaulifier in software forced mode to do it?
i.e.
set up ADC interrupt to read the analog input_A.
If input_A > input_B, then use Action-Qualifier to force PWM to be high. Otherwise to force PWM to be low.
And update the software-forced register in each ADC interrupt.
I was trying to use the on-chip analog comparator to do it, but I had to convert the internal value to analog signal (DAC) and I was not sure about Ramp Generator.
Any suggestion or comments will be appreciated.
Frank
Frank,
In this case you don't need to use PWM module. You can manipulate an output as GPIO pin.
Frank,
Roman's response is probably the best way and should be pretty easy to implement.
However, if you need the response to be very quick (ideally without computation), you should probably continue exploring the on-chip comparators. Note that the comparator's output can be directly sent to a pin. (for example, GPIO34 can be configured to be Comparator 3's output)
Thank you,
Brett
If I want to use the on-chip comparator, then I have to convert the internal input (which is time varying) to analog signal.
Doesn't it actually slow the process down?
Frank
Frank,
My response assumed that the internal input (input_B) would be slowly varying or constant. If instead, it is rapidly changing, my response is less useful.
Thank you,
Brett
Hi Roman,
How should add deadband if I use GPIO instead of ePWM module?
Thanks,
Frank
Hi Frank
It depends on the dead time duration. If you need deadband less than 1us just use few NOPs. If you need more continuous time interval NOPs will decrease your MCU efficiency and in this case you should better use PWM module. :)
You can easily alter your project from GPIO to PWM but you need add a lot of code to configure PWM module. Some examples are in the SPRU791.
Regards,
Roman
Hi Roman,
Thank you for your reply.
The reason I wanted to use GPIO as output (after you suggested in the beginning) instead of ePWM module was that I wanted to avoid using ePWM interrupt.
If you see my original question under this topic, I was already using ADC interrupt to take the feedback in my project. I don't know if getting another interrupt into the system will bring more problems. All the examples I have seen from ControlSUITE or SPRU791 use only one interrupt in each program.
Do you have any suggestions, like things I need to be aware of, or any resources I can find examples with two or more interrupts in one system?
Thank you so much and Happy New Year,
Frank
Hi Frank
search for the "realtime" example under <CCS Install dir>\tutorial\dsk2812\realtime for the multiple interrupts example. it is not for 28035 but I think there are no big differences in the interrupt system. C2000 MCUs can manage a lot of interrupts and I have never had any problems with it.
But I don't understand why you need an addition interrupt in case you are using PWM module to control IO pin in style you talk in your original question. All you need is to set up all this PWM control registers in the way you need and you can manipulate IO pin through forcing AQ high or low. The dead time will be automatically added.
The advantage of using GPIO is simplicity because all you need is to set up the GPIO pin direction. It's good for beginning. But in case you need dead time generation the better choice is PWM module (in case you can't use NOPs :). Configuring of the PWM control registers will take some time but ones you do this you can forget about it. And don't forget to enable clock for the PWM module.
As for interrupts you just have to write second ISR, enable some flags in PIEIER and IER registers. Typical application uses a lot of interrupts.
Regards.