How can I make 4ch PWM using CY8C24894-24LTXI

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        Hi, I want to make below PWM function. PSoC1 : CY8C24894-24LTXI (DBB00,DBB01,DCB00,DCB01) PWM : 4ch PWM interval : 10ms PWM resolution : 10us (Ideally 1us) PWM width : 0 - 2ms (2000us) Now I'm using Timer8 which interrupt interval is 10[us]. Timer8 Interrupt function is just increasing counter, and comparing between PWM width and counter value and switching GPIO control(high/low) are done in the main function. Just so you know, comparing value and 4ch GPIO switching don't finish within 10[us], so those code are in the main function. But the problem is accuracy of PWM isn't that great. So could you tell me how I do to solve this problem. Note: - It's impossible to place 4ch PWM16 - It's possible to place 4ch PWM8 but I'd like to set PWM resolution as 10us while PWM width is 10ms. Thanks   
0 Likes
4 Replies
Anonymous
Not applicable

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.      

   

Use interrupt.      

   

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?      

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 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,

   

Prem Sai 

0 Likes
Anonymous
Not applicable

Hi there,      

   

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.      

0 Likes