This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with GPIO Input switch in our board

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?

  • Hello Blueshift,

    There are a few things not clear here and some comments in general.

    1 The Pin PD7 is a locked pin and needs to be unlocked for a GPIO pin function

    2. In the key press function the reference is to Pin PMx_KEY. In the description before that you have mentioned Port D but the code seems to refer to Port M.

    Regards

    Amit

  • Hi Amit,

    That issue is solved. PD7 is NMI pin and need to unlock that as followed in COMMIT Register process section in datasheet. Thanks.

  • blueshift g5 said:
    PD7 is NMI pin and need to unlock

    Further support/evidence in behalf of the claim that, "GPIO Problems" and/or "TM4Cxxx NMI Unlock" (Sticky Titles) remain, "too indirect" to save user-clients this fate.  Further - does not the same fate await those many users of LX4F?  (Mais certainement)

    "PF0, PD7, PE7 Alert" is far more direct/notable!  (and inclusive of any/all parts awaiting this pitfall...)

  • Hello cb1,

    Agree (without any questions/comments). However curiosity warrants that how it worked in the Development Platform if the SW code was the same?

    Regards

    Amit

  • Amit Ashara said:
    curiosity warrants that how it worked in the Development Platform if the SW code was the same?

    Indeed - might that be explained by the fact that user is using a "very wide" 8 bit port - exposing the dreaded NMI pin?  (We don't have that board - yet it's rare for an EVK to use all 8 port pins as inputs!   Sense that's likely explanation/curiosity killer...)

    User's statement of SW code being the same cannot be correct!  (EVK unlikely to have read whole port)

  • Hi Amit and cb1,

    The Development board is using complete Port M for input keys. I meant the SW code logic worked on Developement board and not on our target board. My bad I must have followed the datasheet correctly. Apologies.

  • Hello Blueshift

    Thanks for the clarification. Now that closes the issue for sure.

    Regards

    Amit