- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello:
I´m using a cy8c29566-24AXI and I connected Buttons in pull Up with drivemode option in the pinout in port2 but two buttons always appear like if were Press but I don´t know why, I prove with a pull up external and I have the same result. some one know why? or how can I fix the problem?
Solved! Go to Solution.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This line of code in button poll -
if (((PRT2DR & 0b00000001) | (PRT2DR & 0b00100000) | (PRT2DR & 0b00000100) | (PRT2DR & 0b00001000) | (PRT2DR & 0b00010000)) != ( 0b00111101)){
What is the test for at the end of the code ?
You have buttons on P2_0, P2_2, P2_3, P2_4, P2_5, correct ?
Note change the name in pin editor of each button to its functional
name so when you look at pinview its clear what each pin does.
Consider doing one read on PRT2DR like -
keycheck = PRT2DR; // Get port 2 data
if ( ( keycheck | 0b11000010 ) != 0xFF ) break; // If any key down break (force non
// button pin position in data to
// true in this test)
Also, you do not debounce your keys in and out. Mechanical keys should be
debounced for at least 100 mS. And do you want key to be released before you
operate on it, code does not reflect that.
Attached debounce techniques.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your button is wired Vss to Pin, and an internal pullup exists, pin to
Vdd, then detection of button closed is a logic 0 for that bit in the port.
Otherwise that bit will reflect the pullup and always be at logic 1.
Note use shadow registers if you have mixed I/O in the port, see
following ap note for discussion.
http://www.cypress.com/?rID=2900 AN2094
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I only use the port For Buttons and use the operation & to obtaint the pin value. I prove in Pull Down and I have the same problem. First I prove the code in a protoboard and it work fine, but in the PCB I have this problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would initialize the port by writing 0xFF to it when you start program.
Also setting port pins, in the pins editor, initial state as "1". That actually
would take care of a 0xFF write to the port.
Post your project and we can take a look at it.
"File"
"Archive Project"
Obviously if PCB is suspicious look at actual copper routes for the buttons
and determine if they are correct.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I attached My code
I chek continuity between the pin and button and they have continuity. only the Pin 2[1] and P2[7] don´t work
- 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
Hello
I try to attach the code but I can´t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use Internet Explorer or Firefox to attach code.
Chrome has problems.
Regards, Dana.
- 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
This line of code in button poll -
if (((PRT2DR & 0b00000001) | (PRT2DR & 0b00100000) | (PRT2DR & 0b00000100) | (PRT2DR & 0b00001000) | (PRT2DR & 0b00010000)) != ( 0b00111101)){
What is the test for at the end of the code ?
You have buttons on P2_0, P2_2, P2_3, P2_4, P2_5, correct ?
Note change the name in pin editor of each button to its functional
name so when you look at pinview its clear what each pin does.
Consider doing one read on PRT2DR like -
keycheck = PRT2DR; // Get port 2 data
if ( ( keycheck | 0b11000010 ) != 0xFF ) break; // If any key down break (force non
// button pin position in data to
// true in this test)
Also, you do not debounce your keys in and out. Mechanical keys should be
debounced for at least 100 mS. And do you want key to be released before you
operate on it, code does not reflect that.
Attached debounce techniques.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Danna My problem was resolved with your tips 🙂 I've implement the debounce and it works!!! maybe exist Noise in the trace of my PCB
Thanks Danna is a god TIP!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No gods here in the forum, all of us students.
Glad to assist.
Regards, Dana.