Hi a b,
You have difficult problem.
10ms period and 10us resolution. Ratio is 1000.
Not only that you want four.
It seems impossible but. doable.
Because, Cypress said PSoC can, MCU can't Anyway.
How ever it's seems difficult way still.
Count a inner counter value by Each terminal interruption of PWM.
10us is available by that interruption process. I presume so.
Do you hope you can be with this way?
Since your selected device only got 4 DBBs. So your PWM can only be 8 bits wide, giving you a resolution of 1/250 period.
That is 10ms/250 = 40µs. If that is sufficent you can do it in PSoC1 hardware without CPU intervention
With a clock of 24MHz you can scale it down to 25kHz with the VCn dividers giving you a PWM period of 10ms when counter is set to 249.
Another choice could be to use a Cy8C27243-??? which costs more, but not too much. With that chip you are able to use 16-bit PWMs that will give you sufficent resolution.
Hi a b,
If you need to use only CY8C24894, looks like the suggestion by PSoC73 of using the PWM's interrupt would be effective, ie, here is a possible hardware-firmware processing sequence that may meet 10us pulse width during a period of 10 ms:
1) Set the PWM period parameter as 249 and clock it such that its period is 2.5 ms (instead of 10 ms).
2) Set the PWM compare type as "Less than", and pulse width as "0".
3) Use PWM's terminal count interrupt. During each interrupt, increment a variable(starting from 0) by 1. When this variable reaches 4, change the PWM pulse width to 1 using "PWM8_WritePulseWidth" API, and also reset the variable to 0. (Also if this variable is 0 when the ISR is entered, change the PWM pulse width back to 0).
This reduces the firmware interruption to once in 2.5 ms, which should give the CPU enough time before next interrupt. But note that you would have to change the above logic based on the required pulse width of the PWM.
Thanks & Regards,
I should be add and change previous post a little.
For the interrupt, should be use COMPARE INTERRUPT.
It will get more accurate timing.
We have to mention to use PWM module.
It is a count-down counter, start with period value(M) and end with zero.
the period is M+1, and count value is calculate as 255-(value).
the PWM output should be control by software in interrupt routine,
If meets the conditions should be turn ON the output.
Otherwise turn OFF.
When compare interrupt was happen and inner counter
meets the condition, change The PWM output.
Each Interrupt routine should be process enough within 10u.sec
It might could be.