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.

TM4C1294NCPDT: How to set up GPIO pin PJ0 of TM4C1294NCPD as an input with a pull-down resistor

Part Number: TM4C1294NCPDT


Hi Team,

Our customer would like to know how to set up GPIO pin PJ0 of TM4C1294NCPD as an input with a pull-down resistor. Below is his source code.

void SW_Init(void){
SYSCTL->RCGCGPIO |= 0x00000100; // activate clock for Port J
while((SYSCTL->PRGPIO&0x00000100) == 0){;} // allow time for clock to stabilize

GPIOJ_AHB->DIR &= ~0x01; // make PJ0 in //& PJ1 in
GPIOJ_AHB->AFSEL &= ~0x01; // disable alt funct on PJ0 & PJ1
GPIOJ_AHB->PUR |= 0x00; // disable pull-up on PJ0
GPIOJ_AHB->PDR |= 0x01; // enable pull-down on PJ0
GPIOJ_AHB->DEN |= 0x01; // enable digital I/O on PJ0 //& PJ1
GPIOJ_AHB->AMSEL &= ~0x01; // disable analog functionality on PJ0 //& PJ1
GPIOJ_AHB->PCTL = (GPIOJ_AHB->PCTL & 0xFFFFFFF0)+0x00000000;

GPIOJ_AHB->IM &=~0x01; // Clear GPIOM before programming GPIOS,GPIOBE,GPIOEV
GPIOJ_AHB->ICR|= 0x01; // Clear Interrupt Flag
GPIOJ_AHB->IS &=~0x01; // PJ0 is edge-sensitive //& PJ1 are
GPIOJ_AHB->IBE &=~0x01; // PJ0 & PJ1 Interrupt is triggered by single edge
// GPIOJ_AHB->IEV &=~0x01; // PJ0 Interrupt is triggered by falling edge
GPIOJ_AHB->IEV |= 0x01; // PJ0 Interrupt is triggered by rising edge
GPIOJ_AHB->IM |= 0x01; // Enable PJ0 //& PJ1


NVIC_EN1_R |=0x00080000; // Enable Interrupt number 51 which is bit 19 in EN1
NVIC_PRI12_R = (NVIC_PRI12_R&0x00FFFFFF)|0x80000000; //Set the priority value to 4 in INTD of PRI12 Register. (page 159/160)
}

Thank you for your support.

Regards,

Danilo

  • Hello Danilo,

    We don't recommend customers use direct register calls like this to program with TM4C devices and we don't support such questions on E2E typically. They should download TivaWare and use our driverlib to easily do this.

    TivaWare: https://www.ti.com/tool/SW-TM4C

    The code in TivaWare would be as follows:

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ))
        {
        }
        
        GPIODirModeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_DIR_MODE_IN);
        GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0,
                         GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);
        GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_RISING_EDGE);
        GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0);

    See if the customer will accept this solution.

  • Hi Ralph,

    Thank you very much for your response and suggestion.

    Regards,

    Danilo