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} };
As a test, I tried this:
#define EMPTY_CODE 'Z' #define RIGHT_ARROW 'R' #define LEFT_ARROW 'L' #define ESC 'E' #define DEL 'D' #define CAPS 'C' #define ENTER 'E' #define BUTTON_COUNT 16 #define KEY_TABLE_WIDTH 5 void list_buttons( void ) { unsigned char row; unsigned char col; for( row = 0; row < BUTTON_COUNT; ++row ) { for( col = 0; col < KEY_TABLE_WIDTH; ++col ) { printf( "buttons[%2d][%2d] = '%c'\n", (unsigned int)row, (unsigned int)col, buttons[row][col] ); } printf( "\n" ); } }
buttons[ 0][ 0] = '8' buttons[ 0][ 1] = 'u' buttons[ 0][ 2] = 'ü' buttons[ 0][ 3] = 'v' buttons[ 0][ 4] = 'Z' buttons[ 1][ 0] = '7' buttons[ 1][ 1] = 'r' buttons[ 1][ 2] = 's' buttons[ 1][ 3] = 's' buttons[ 1][ 4] = 't' buttons[ 2][ 0] = '6' buttons[ 2][ 1] = 'ö' buttons[ 2][ 2] = 'p' buttons[ 2][ 3] = 'q' buttons[ 2][ 4] = 'Z' buttons[ 3][ 0] = '5' buttons[ 3][ 1] = 'l' buttons[ 3][ 2] = 'm' buttons[ 3][ 3] = 'n' buttons[ 3][ 4] = 'o' etc
Did you look in your hex code for '8uüv.' ? Was it there before '7rsşt'? The micro cannot "find" the keys (8, ...). What did it find? Do you get overlay errors when you link?
Jon, Yes, I checked the matrix with debugger and 8uü were there before 7... And, with debugger there was not any problem. It works fine in the debugger.
and, yes there was no compiler/linker warnings. Also, I disabled overlaying using nooverlay flag of the linker.
Interesting, can I see the good and bad code?
Jon, I know that it sounds weird. And in fact there is no good code. :) The function may be a bit long to post here, so I can email it to you if you send an email to bahrio at yahoo dot com.