Question: Given the following code and keypad layout, what will the function GetKey() return when it is run while keys 2, 3, 7, B, E, and
Given the following code and keypad layout, what will the function GetKey() return when it is run while keys 2, 3, 7, B, E, and F are pressed?
DDRH = 0x0F; RDRH = 0x00; PERH = 0x00; PIEH = 0x00; PTH = 0x0F; unsigned char GetKey(void) { unsigned char KeyMask[16] = { 0xEE, 0xDE, 0xBE, 0x7E, 0XED, 0xDD, 0xBD, 0x7D, 0xEB, 0xDB, 0xBB, 0x7B, 0xE7, 0xD7, 0xB7, 0x77 }; int i; char Key; for (Key=0, i=0; i { PTH = KeyMask[i]; if (PTH == KeyMask[i]) { if (i else Key = A+ i - 10; } } PTH = 0x0F; return (Key); }
0 Assert PORT keypad row o o PORTkeypad row11 PORT2 keypad row2 2 4 Assert Assert Assert keypad row 3 3 PORTx 3] Vcc 4 10 K Read kevpad column 0 PORTx 4] Vcc 10 K Read keypad column 1 PORTx[5) Vcc 10 K Read keypad col umn 2 PORTx[6] Vcc 10 K Read keypad column 3 PORTx[7]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
