- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Awesome! Thanks, I will try both methods and see type of result best suit us. Thanks for your help!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.