Changing pulse width in PWM generator without using API | Cypress Semiconductor
Changing pulse width in PWM generator without using API
I go straight to the point:
I need to know how to 'change' the pulse width (compare value) of 16 bit PWM generator at run time without using the PWM16_WritePulseWidth() function (I'm using a CY8C29466).
Now if anyone want to know more here's 'why':
I'm writing a simple app that should act as follow:
- should generate 8 pulses each of a variable width of 1 to 2 ms
- all the pulses should be 'enclosed' in a frame that need to 'last' for no more than 20ms
- each pulse (the first in the frame as the second or any else) should 'repeat' with a period of 20ms
I used a 16 bit PWM generator clocked @ 2MHz with a 'period' of 5000 ticks -> 2.5ms
I set the interrupt type of the PWM16 as 'terminal' count. When the 'interrupt' is triggered I take the width of the nth pulse from an array and pass it to PWM16. I'm using PWM16_WritePulseWidth but, since it's an API call, it will lead to a certain overhead that should translate into delays.
If anyone would suggest a different approach I'm open to any suggestion.