Other Parts Discussed in Thread: TM4C1231H6PM
Hi,
I am having DK-TM4C123G Development Board and on that we have successfully tested that Keys Debounce algorithm in sample 'qs-logger' project.
Now I want to test the keys on my board based on TM4C1231H6PM. All 8 keys are on Port D. Only difference in hardwares of Development Board and our board is all the keys are externally pulled up at 3.3V through 10k resistor.
The Key Debounce code works on Development board.
//Initialization of KEYS
void initKeys(void)
{
//
// Enable the GPIO port to which the pushbuttons are connected.
//
MAP_SysCtlPeripheralEnable(BUTTONS_GPIO_PERIPH);
//
// Set each of the button GPIO pins as an input with a pull-up.
MAP_GPIODirModeSet(BUTTONS_GPIO_BASE, ALL_BUTTONS, GPIO_DIR_MODE_IN);
MAP_GPIOPadConfigSet(BUTTONS_GPIO_BASE, ALL_BUTTONS,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
//
// Initialize the debounced button state with the current state read from
// the GPIO bank.
//
g_ui8ButtonStates = MAP_GPIOPinRead(BUTTONS_GPIO_BASE, ALL_BUTTONS);
gKeysStatus.Val = 0;
}
/Following keysPoll() function is the same as defined in Keys Debounce of sample project. It just calls the following function instead of returning a value:
keysProcessFlags(~g_ui8ButtonStates, *pui8Delta);
//----Defination of keysProcessFlags() function
void keysProcessFlags(uint8_t keyState, uint8_t keyChanged)
{
uint8_t pressedState = keyState & ~(0x00);
/********** General Button Flags *********/
//UP Button > Up Eval
if(isPowerOfTwo(pressedState)) {
if(BUTTON_PRESSED(PM4_KEY_UP, keyState, keyChanged)) {
if(!gKeysStatus.bits.Key_Up_pressed) {
gKeysStatus.bits.Key_Up_pressed = true;
}
}
}
if(!pressedState)
if(BUTTON_RELEASED(PM4_KEY_UP, keyState, keyChanged)) {
if(!gKeysStatus.bits.Key_Up_released) {
gKeysStatus.bits.Key_Up_released = true;
gKeysStatus.bits.Key_Up_pressed = false;
}
}
//Down Button > Down Eval
if(isPowerOfTwo(pressedState)) {
if(BUTTON_PRESSED(PM5_KEY_DOWN, keyState, keyChanged)) {
if(!gKeysStatus.bits.Key_Down_pressed) {
gKeysStatus.bits.Key_Down_pressed = true;
}
}
}
if(!pressedState)
if(BUTTON_RELEASED(PM5_KEY_DOWN, keyState, keyChanged)) {
if(!gKeysStatus.bits.Key_Down_released) {
gKeysStatus.bits.Key_Down_released = true;
gKeysStatus.bits.Key_Down_pressed = false;
}
}
}
Where am I going wrong?