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.

Setting GPIOCTL bits



I trying to use I2C2 on an LM4F231 using CCS5. I understand that the GPIOCTL bits in Port E to select the I2C peripheral. Is this something I must do explicity or is there a StellarisWare library routine that will help me?

I expect to see a call that involves GPIO_PE4_I2C2SCL and GPIO_PE5_I2C2SDA but haven't been able to find it. Also, supporting this is that GPIO_PCTL for port E is at zero after I set up the I2C hardware.

Thanks

  • It seems that I'm getting good at answering my own questions - or being able to ask questions with reasonably obvious answers!

    The function desired is GPIOPinConfigure() where the parameter is taken from the appropriate section of pin_map.h. This has the prequisite that "driverlib/pin_map.h" be included prior to the call.

  • David,

     

    To enable the I2C peripheral you must first enable the port then configure the pins for their I2C function. This can all be done using StellarisWare calls:

     

    // GPIO port E needs to be enabled so these pins can be used.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

     

    // Configure the pin muxing for I2C0 functions on port E4 and E5.

    GPIOPinConfigure(GPIO_PE4_I2C2SCL);

    GPIOPinConfigure(GPIO_PE5_I2C2SDA);

     

    Also make sure you include the correct headers to support the functions you would like to use:

    #include "driverlib/i2c.h"

    #include "driverlib/gpio.h"

     

     For more information please see the documentation included within StellarisWare. "<Your StellarisWare install directory>/docs". Also leveraging some existing examples can help as well.

  • David Pfaltzgraff said:
    function desired is GPIOPinConfigure()

    You may wish to consider function GPIOPinType() as well.  These 2 functions are often bound together - more modern, high performance MCUs require such treatment...