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.

TM4C1230H6PM: Can't able to toggle the GPIO pin

Part Number: TM4C1230H6PM

Tool/software:

Hello!!

I am using TM4C1230H6PM controller in my project, i am using PB1(pin no 46) as an output pin and trying to toggle that pin but it is not getting toggled even if an tring to make the pin high it is staying in low. what might be the issue ??? i have checked with other pins PB2 and PB3 there also it is happening in the same way in that port i can able to toggle only the PB0 pin. here is my code please have a look and suggest me if any changes..

#include "main.h"

int Index = 1;
int count;
int check_release,relese_couter;	
extern uint8_t rev_data[3];
int value;
#define GNSS_OFF "GF0"
#define GNSS_ON "GF1"
#define SYNC_OFF "SW0"
#define SYNC_ON "SW1"
#define HOLD "HLD"

void Keypad_Init(void)
{
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //LED
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	
 //  This is using for the PD7 Pin
	HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80;
	HWREG(GPIO_PORTD_BASE + GPIO_O_AFSEL) &= 0x80;
	HWREG(GPIO_PORTD_BASE + GPIO_O_DEN) |= 0x80;
	HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0;
/*
	HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTB_BASE + GPIO_O_AFSEL) &= ~(1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_AMSEL) &= ~(1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_DEN) |= (1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_DIR) |= (1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_ODR) &= ~(1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_PUR) |= (1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_PDR) &= ~(1 << 1);
	HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = 0;
*/
									/******* KEYPAD PB *********/
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0);
	ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPD);
	
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_1);
	ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPD);
	
	
	ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1,0);
	delay(1000);
    ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1,1);
	
	

  • Hi,

      I see one issue with your below line of code to set PB1 to high. In your code, you are actually trying to set PB0 high instead of PB1. Note that bit0 is for PB0, bit1 is for PB1, bi2 is for PB2 and so on. To set PB1 high, you would need to set the value to 0x2 instead, not 1 as in yours. This is why it is best to use the MACRO as provided in the library instead of a raw value. For example, to set PB1 high, you would write ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1,GPIO_PIN_1). To set PB2 high you would write ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2,GPIO_PIN_2). Writing this way, you will eliminate careless mistakes. 

        ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1,1);