cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

YuMa_1534086
Contributor

Hello.

 

Attached project uses 2 PWM components.

PWM makes square wave, and this square wave is stopped or started by PWM_Timer interrupt.

 

Attached pptx file is waveform of this square wave.

 

Sometimes it takes some time for voltage level to reach GND when square wave is stopped.

Please confirm red circle of attached pptx file.

 

 

Q1)

Could you please let us know reason why this behavior occurs?

Does this behavior occur if PWM is stopped when voltage level is high?

Why doesn't voltage level go to GND immediately?

 

Q2)

Could you please let us know solution to this behavior?

I want to immediately set voltage level to GND regardless of timing that PWM_stop is called.

 

 

Best Regards.

Yutaka Matsubara

0 Likes
1 Solution
Aashita_Raj
Moderator
Moderator

Hi @YuMa_1534086 ,

We tried to re-produce the issue on our end so that we can get rid of it. We have made the following changes in main.c of your attached  project and now, we are able to escape the exponentially decay of the square wave-

1. Added a line of code after PWM_Stop(),  to enable HSIOM for PIN to be software controlled since there is a hardware connection of PIN to Tcpwm in TopDesign.cysch.

2. Since the PIN is already set to Strong Drive, we kept it unchanged. This is important to take into account because such waveform as PWM.pptx occurs when PIN is previously driven high and is left at HiZ.

3. Added a line of code writing 0 to the PIN after this.

We also added a line of code for configuring HSIOM register back for hardware connection before PWM_Start().

I have attached the main.c which has all the changes made, for your reference. Please make these changes on your end and let us know if this solves your issue or in case of any further query.

Best Regards,

Aashita

 

 

View solution in original post

0 Likes
6 Replies
Aashita_Raj
Moderator
Moderator

Hi @YuMa_1534086 ,

I went through the attached project of yours and the PPT showing the exponentially decaying square wave. It doesn't seem to be an issue due to PSoC's behavior . However, to confirm this - Can you please go through my queries below so that we can help you out with the proper solution?

1. Can you please try checking the output with different pins of the PSoC and let us know the results?

2. Also, you can try with different pin drive modes and check if one of the drive mode solves this issue?.

3. This might be an oscilloscope issue. So, you can try using different probe and check with the process, which you are using to measure the square wave .

Please follow the comments we have made above and let us know in case of further queries.

Best Regards,

Aashita

 

0 Likes
YuMa_1534086
Contributor

Aashita-san.

 

Please confirm below my answer.

If you have CY8CKIT-149, you can reproduce this symptom.

 

=======================================

  1. Can you please try checking the output with different pins of the PSoC and let us know the results?

=> This symptom was also confirmed with other pins.

 

  1. Also, you can try with different pin drive modes and check if one of the drive mode solves this issue?.

=> Other pin drive modes also did not solve this symptom.

 

  1. This might be an oscilloscope issue. So, you can try using different probe and check with the process, which you are using to measure the square wave .

=> This symptom was also confirmed using other oscilloscope or other probe.

=======================================

 

Best Regards.

Yutaka Matsubara

0 Likes
Aashita_Raj
Moderator
Moderator

Hi @YuMa_1534086 ,

We tried to re-produce the issue on our end so that we can get rid of it. We have made the following changes in main.c of your attached  project and now, we are able to escape the exponentially decay of the square wave-

1. Added a line of code after PWM_Stop(),  to enable HSIOM for PIN to be software controlled since there is a hardware connection of PIN to Tcpwm in TopDesign.cysch.

2. Since the PIN is already set to Strong Drive, we kept it unchanged. This is important to take into account because such waveform as PWM.pptx occurs when PIN is previously driven high and is left at HiZ.

3. Added a line of code writing 0 to the PIN after this.

We also added a line of code for configuring HSIOM register back for hardware connection before PWM_Start().

I have attached the main.c which has all the changes made, for your reference. Please make these changes on your end and let us know if this solves your issue or in case of any further query.

Best Regards,

Aashita

 

 

View solution in original post

0 Likes
YuMa_1534086
Contributor

Dear Aashita-san.

 

Thank you for your response.

 

PWM output of project I sent first was P5_3.

 

Did you change PWM output terminal from P5_3 to P2_7?

Because you used SEL2 instead of SEL5.

=======================================

CY_SET_REG32((void *)(CYREG_HSIOM_PORT_SEL2), 0x80000000u); 

=======================================

 

This symptom was solved by changing PWM output terminal from P5_3 to P2_7 and using your file.

 

 

>>>Since the PIN is already set to Strong Drive, we kept it unchanged.

What should I do if I want change pin drive mode?

Should I use API of SetDriveMode ?

Or is it better to operate registers directly?

 

 

Best Regards.

Yutaka Matsubara

0 Likes
Aashita_Raj
Moderator
Moderator

Hi @YuMa_1534086 ,

->>Yes! We tried to test the project on PSoC 4000S device, so we changed the PWM output terminal to P2.7 and probed it to see the waveforms on the oscilloscope.

->>Also, You can go through the GPIO Interface Overview  and I/O Cell Architecture in the device architecture TRM for more information about HSIOM.  GPIO pins are connected to I/O cells. . The digital peripherals connect to the I/O cells via the high-speed I/O matrix (HSIOM). HSIOM contains multiplexers to connect between a peripheral selected by the user and the pin. 

Since there is a hardware connection of Pin P2.7 to the PWM o/p terminal in TopDesign.cysch, we tried writing the value 0x00000000 to HSIOM port register 2 in order to make it software controlled. Then we were able to write 0 to the Pin using API Pin_Write(0). Please go through the Registers TRM  of the device which you are using, for more information about registers. 

->>I meant that since you have already configured "Strong Drive" as drive mode for the pin attached to PWM output terminal in TopDesign.cysch , you need not write a line of code in your project to set the drive mode for that pin.  However,  you can use Pin_SetDriveMode() API to set the drive mode for that pin in software. Please go through the Pin Component datasheet of PSoC Creator for more information on the usage of APIs.

Best Regards,

Aashita

0 Likes
YuMa_1534086
Contributor

Aashita-san.

 

Thank you for your response.

 

I understand.

 

Best Regards.

Yutaka Matsubara

0 Likes