Pull Up Problem

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

cross mob
Anonymous
Not applicable

 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?

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

View solution in original post

0 Likes
11 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

 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.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

 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

0 Likes
Anonymous
Not applicable
0 Likes
Anonymous
Not applicable

Hello

I try to attach the code but I can´t

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Use Internet Explorer or Firefox to attach code.

   

 

   

Chrome has problems.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        Here is my code   
0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

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!!! 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

No gods here in the forum, all of us students.

   

 

   

Glad to assist.

   

 

   

Regards, Dana.

0 Likes