PWM Square Wave of 38 kHz using Systick Timer

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

cross mob
lock attach
Attachments are accessible only for community members.
ShVy_264716
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hey All

   

How is everyone doing? Hope all of you are enjoying the start of the year 2016 and getting more and more fascinated with PSoC like me.

   

Today I have taken a task to Generate a 38kHz square wave with PSoC4 using a SysTick Timer. I have even designed a project related to that. My design, theoretically, will give square wave of around 38.4 kHz due to clock resolution limitation of PSoC4 that is 24 MHz.  I was checking the wave on CRO. (please find attached the CRO result image.) As it gave me some triangular wave, I decreased the frequency to 100 Hz and checked again with CRO. This time I got the perfect square wave.

   

I kindly request you to please find attached my project designed for 38.4 kHz and give me a solution to get a perfect square wave. In addition, if anyone of you can give me a solution to get a perfect 38 kHz square wave than the current design of 38.4 kHz, I will be very much thankful.

   

 

   

Thanks and Regards

   

Shaunak

0 Likes
8 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Shaunak: P1.7 is a voltage reference pin for the chip and has a 1.0uf cap on it that is why you where getting a triangular wave form. You need to move it to another pin.  If you are looking for the led pin it is on P1.6.  Also your clocks where not setup correctly in the clocks .crdwr the WDT2 was not enabled.  Also the components where out of date. Please update to Psoc Creator 3.3.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Shaunak: Here is your program with the fixes installed.  This was done on the following Psoc Creator  3.3 CP1.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Shaunak,

   

There is one approach producing high-resolution PWM using dithering technique:

   

http://www.cypress.com/blog/psoc-hacker-blog/high-resolution-high-frequency-pwm-psoc4-ble

0 Likes
lock attach
Attachments are accessible only for community members.
ShVy_264716
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

@bobgoar: I just checked my Cypress Update Manager, but there isn't any new update available for Creator. And I am not able to understand the project shared by you as I can see there is a user defined component "PWM_3CMP_v1_00" in that, the source of which is not available so the project building generates an error. Please find attached the snapshot of my Creator.

   

@odissey1: The link is good, but my current problem is that I can not use a Creator component for PWM due to memory constraints.

   

 

   

Thank you very much guys for responding.

   

 

   

Regards

   

Shaunak

0 Likes
lock attach
Attachments are accessible only for community members.
ShVy_264716
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

What I am thinking now is to set a clock of 38 kHz and give it to the Pin. Please find attached my project which is not working as of now.If anybody can make it working, then it will be a good achievement for him/her.

   

 

   

Regards

   

Shaunak

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Shaunak: I found that your output pin was set for digital input and output I set it for output only.   Can I ask  you what is not working with this program? The program compiled fine with no errors. 

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Shaunak: You also forgot to start the Clock component.  I am sending you your program back with these changes.

0 Likes
lock attach
Attachments are accessible only for community members.
ShVy_264716
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

@bobgoar: I used your project, but not succeeded yet.

   

Please find attached herewith the snapshot of my CRO.

   

 

   

Regards

   

Shaunak

0 Likes