Read-Only Author Bahri Okuroglu Posted 23-Oct-2001 08:35 GMT Toolset C51 |  accessing array's row 0 Bahri Okuroglu I have a matrix for the keyboard layout in my program as follows:
code unsigned char buttons[BUTTON_COUNT][KEY_TABLE_WIDTH]
= {
{'8', 'u', 'ü', 'v', EMPTY_CODE},
{'7', 'r', 's', 'ş', 't'},
{'6', 'ö', 'p', 'q', EMPTY_CODE},
{'5', 'l', 'm', 'n', 'o'},
{'1', 'a', 'b', 'c', 'ç'},
{'2', 'd', 'e', 'f', EMPTY_CODE},
{'3', 'g', 'ğ', 'h', 'ı'},
{'4', 'i', 'j', 'k', EMPTY_CODE},
{'9', 'w', 'x', 'y', 'z'},
{'0', ' ', ':', '-', EMPTY_CODE},
{RIGHT_ARROW,EMPTY_CODE, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE},
{LEFT_ARROW, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE},
{ESC, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE},
{DEL, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE},
{CAPS, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE},
{ENTER, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE, EMPTY_CODE}
};
I use this table to use keyboard as in gsm phones to produce letters using 10 buttons.
Code works fine, but when I push on the button 0, it fails to access the row 0 of the array. I can get key '7', but cannot get key '8'. It finds 0x00 for the first row members.
I studied the code produced and tried to investigate using debugger; but they all seem OK to me. However, when I program the AT89C55WD with this code, it cannot find the keys (8, ...) for button 0. Please note all the other keys are OK.
I could not solve this problem, and inserted a dummy row to the table at row 0, and indexed the table with not the button pressed, but with (button+1).
This worked, but since it is just a work-around; I really wonder the reason.
Any ideas? |