This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

4x4 keypad

Hello, i was wondering if anyone could help me, to get my 4x4 keypad scanning function working.
Its supposed to drive each column to zero one at a time and then poll each row in sequence for zeros.

unsigned int scan_key (void) {

int col;

int key_read;

///////////

for(col=0;col++;col=3 ) { ////Go through columns

///////////////////////////////////////////// (GPIO_PORTD_DATA )&=~(0x1<<col);

if (!(GPIO_PORTC_DATA & 0x10)==0)//Polling row0

{ key_read=keypad [0][col]; break; }

///////////////////////////////////////////////// /////////////////////////////////////

if (!(GPIO_PORTC_DATA & 0x20)==0)//Polling row1

{ key_read=keypad[1][col]; break; }

//////////////////////////////////////////////////

if (!(GPIO_PORTC_DATA & 0x40)==0)//Polling row2

{ key_read=keypad[2][col]; break; }

/////////////////////////////////////////////////////////

if (!(GPIO_PORTC_DATA & 0x80)==0)//Polling row3

{ key_read=keypad[3][col]; break; }

}
return key_read; }

Parents
  • 1) Did you happen to forgot to read the posting instructions?

    2) Did your post end up looking like you intended?

    3) Did you try the magic of debugging - like looking closer at your row and column signals for the four iterations? Did you really get the intended result on PORTD? You are only intended to clear bits - never set any bits?

    4) What did you intend to return if no key is pressed? Or didn't you debug that alternative?

    5) What did you intend to return if multiple keys are pressed? Or didn't you debug that alternative?

Reply
  • 1) Did you happen to forgot to read the posting instructions?

    2) Did your post end up looking like you intended?

    3) Did you try the magic of debugging - like looking closer at your row and column signals for the four iterations? Did you really get the intended result on PORTD? You are only intended to clear bits - never set any bits?

    4) What did you intend to return if no key is pressed? Or didn't you debug that alternative?

    5) What did you intend to return if multiple keys are pressed? Or didn't you debug that alternative?

Children
No data