Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Push Button

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Push Button
Moderator:
ANCY

Post Reply
Follow this topic



Push Button

Doacn posted on 08 Jun 2011 10:52 AM PST
Member
10 Forum Posts

Hello,

  I have been using PSoC 5 with this new project and I am trying to figure out why every time I pressed the button (General Purpose Switch button) I kept getting more than one message than I need. I expected that every time I press the button, only need one message and not several at a time.

Attached is the code I had modified to do the push button but it does not seem right to me. Any suggestions on the coding?

 

Thanks!




Re: Push Button

Gautam Das posted on 09 Jun 2011 11:57 PM PST
Cypress Employee
742 Forum Posts

Hi Doacn,

 

SInce you are using the statements in an infinite loop [ for(;;) ], the UART will send the value it reads continuously.

If the value has to be printed via UART only once when the button is pushed, you may use an Interrupt component.

Setting it to Rising edge or Falling edge triggered as per your requirement will enable you to send the value on the required edge. Holding the botton for a longer time will not result in sending of more than one value via UART.

 

This is one way to overcome this issue.



Re: Push Button

hli posted on 09 Jun 2011 12:31 AM PST
Top Contributor
675 Forum Posts

Have a look at AN60024 - Switch Debouncer/. This should solve your problem.



Re: Push Button

Doacn posted on 10 Jun 2011 11:02 AM PST
Member
10 Forum Posts

Awesome! Thanks, I will try both methods and see type of result best suit us. Thanks for your help!!



Re: Push Button

Doacn posted on 10 Jun 2011 01:02 PM PST
Member
10 Forum Posts

Hello Dasg,

  Do you mean to create a new interrupt component or the interrupt component in UART? More clarification please. Thanks.

P.S. I had done both ways and I still get the same result.



Re: Push Button

Gautam Das posted on 11 Jun 2011 08:59 AM PST
Cypress Employee
742 Forum Posts

Hi Doacn,

 

My suggestion was to use an ISR Component connected to the Button_Pin. The schematic will look something like this.

 

 

 

Assume that the Button is connected to ground when pushed, and is left floating when not pushed. Then for this logic, the drive mode of the pin should be configured as Resistive Pull-Up.

 



Re: Push Button

Gautam Das posted on 11 Jun 2011 09:07 AM PST
Cypress Employee
742 Forum Posts

In the ISR routine, a flag can be set. In the infinite loop of the main( ) function, the flag can be polled. When the flag is set, data is transmitted through UART and flag is reset. This way, data is transmitted only once upon push of the button.

For the data to be transmitted again, the button should be pressed again.

The ISR can be configured to be Rising Edge Triggered.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20