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.

Anomaly in Tiva Ware Library GPIO Pin Write: TM4C129x

Hi All,

    I am working with TM4C129x device and I am trying to set the logic level of PortN lines using GPIOPinWrite function and observe that GPIO_DATA register of port n is not being updated and Logic level of GPIO is not changed. Please find the snippet of the code.

 if (SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
   {

   GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_2);
   GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_5);
   GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_2, 1);
   GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 1);
   GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_3);
   GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_3, 1);
   GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_4);
   GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, 1);
   }

   With this code, when Register map for Port N is monitored in CCS, i see that the data written is being updated for GPIODIR direction register but not for GPIODATA register.

   I have used GPIOInterrupt example for Launchpad kit and customized the code for our hardware.

   Software configuration:

   CCSV6
   tirtos_tivac_2_00_01_23
   TivaWare_C_Series-2.1.0.12573c

   Has anybody faced such issue?

    Please let me know if anybody has faced such an issue with GPIOPinWrite.

Thanks and regards,

Gupta

 

  • Hi,

    Shreeranganath Gupta BBV said:
       GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_2, 1);
       GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 1);
       GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_3);
       GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_3, 1);
       GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_4);
       GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, 1);

       See, GPIOPinWrite and example code at Tivaware Peripheral Drivers Library Users Guide. 

    Description:
    Writes the corresponding bit values to the output pin(s) specified by ui8Pins. Writing to a pin
    configured as an input pin has no effect.
    The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to
    be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO
    port pin 1, and so on.

    -kel

  • Markel Robregado said:
    The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to
    be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO
    port pin 1, and so on.

    What's being said here may be more clearly stated as,

    your, GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 1); will fail to yield an output high on the desired pin

    instead would work if you made this change:

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, GPIO_PIN_5);

    or

     GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 32); //  Note that "32" is the value of bit GPIO_PIN_5

    likewise your, GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_3, 1); again will fail

    would work with GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_3, GPIO_PIN_3);

    or

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_3, 8);

    In both cases - your "1" is valid as an output high only for bit 0 - will fail for all other bits!

    Note that many past MCUs would have accepted "1" as high - but not here - and while "unusual" the masking provided by the 2nd parameter w/in GPIOPinWrite() will prove of good value to you...

    Appears that you've jumped right into program code - w/out full benefit of study of the numerous gpio examples - both in the peripheral driver library and in the examples section of the code library.  Such read/review will build your confidence and further define the "unexpected features" which often appear when using a new MCU...

  • Thank you very much Markel. It solved the issue.

    Thanks and regards,
    Gupta