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.

EK-TM4C1294XL: Can GPIO output data be written in advance?

Part Number: EK-TM4C1294XL

I have an external 3-state bus driver, The Enable pin is pulled up by an external resistor and controlled by my GPIO.

The pull-up ensures the buffer is disabled at power up.

Now, I want the buffer to stay in 3-state until I at some later time turn it on. But that requires the GPIO to go '1', when I turn it to be output.

So can it be done like this?

GPIOPinWrite(GPIO_PortF_Base, GPIO_Pin_1,2);  //Set Pin 1 before it is programmed as output
GPIOPinTypeGPIOOutput(GPIO_PortF_Base, 6);     //Pins 1 and 2 as output. Pin 1 should start up in the '1' state?

I.e. writing the state of the output pin before it is set to be output?

Apparently not!

So what can be done about it?

  • There is a workaround. You cannot write the value to the output register until you configure the pins as outputs, but you don't have to enable the digital I/O function before writing to either of those registers. The problem is that the function GPIOPinTypeGPIOOutput() configures the pins as outputs and enables them. You can split the GPIOPinTypeGPIOOutput() function with separate calls to GPIODirModeSet() and GPIOPadConfigSet() with a call to GPIOPinWrite() in the middle. Try this code:

        GPIODirModeSet(GPIO_PORTF_BASE, (GPIO_PIN_1 | GPIO_PIN_2), GPIO_DIR_MODE_OUT);
        GPIOPinWrite(GPIO_PORTF_BASE, (GPIO_PIN_1 | GPIO_PIN_2), (GPIO_PIN_1 | GPIO_PIN_2));
        GPIOPadConfigSet(GPIO_PORTF_BASE, (GPIO_PIN_1 | GPIO_PIN_2), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    

  • Thanks for posting this. I wanted to do this a few months ago, and now I know how.

  • I found another solution that also works, but only because the buffer is bi-directional.

    I set my TI data pins to be input

    I set the buffer direction to input. (direction TI board)

    And then I turn the enable pin into output mode

    And disable the buffer by setting enable pin to '1'.

    .

    Your code could come ind handy at a later time!

    Where are all those strange macros described? A new one seems to pop up every single day!