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.

Getting output from GPIO

Other Parts Discussed in Thread: TM4C123GH6PM

I am using TM4C123GH6PM kit.I am try to get output from PA6. I am using multimeter to check the output. But the pin doesn't produce any output. May I know the problems with detail?. My code is,

#include<stdint.h>
#include<stdbool.h>
#include"inc/hw_memmap.h"
#include"inc/hw_types.h"
#include"driverlib/sysctl.h"
#include"driverlib/gpio.h"

uint8_t ui8PinData=64;

int main(void)
{
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_6);

    while(1)
    {
        GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6,ui8PinData);

    }

}

  • Can think of only 3 things which may cause:

    a) provide some delay just after you, "SysCtlPeripheralEnable()" Port A.  MCU requires some time to process.

    b) perhaps your MCU "defaults" Port_A6 into some alternate function - in which case, "GPIOPinTypeGPIOOutput()" by itself - will be insufficient to escape the default.  Good read of the GPIO section - your specific MCU manual - should reveal  

    c) you've some unwanted/excessive "load" upon PA6 - which prevents that output from rising...

  • I tried the code with delay. And I use

    #define GPIODEN 0x40058020;

    #define GPIOAMSEL 0x40058000;

    #define GPIOAFSEL 0x40058020;

        registers for good configuration. And i tried with PA5 pin also. But the i don't receive any output.

  • Hello M.Mary,

    The definition of the register is wrong.

    #define GPIODEN 0x40058020;

    #define GPIOAMSEL 0x40058000;

    #define GPIOAFSEL 0x40058020;

    should be

    #define GPIODEN 0x4005851C

    #define GPIOAMSEL 0x40058528

    #define GPIOAFSEL 0x40058420

    Regards

    Amit

  • And - as always - API via driver library "prevents" such misdefinition!  API is free, powerful, (mostly) proven.  Your direct register usage - not quite the case...

    You may eliminate my fear of "default" GPIO behavior - operating against your desired usage - by switching to another Port/Pins - and testing there.

    Unstated is what (if anything) had past been connected to PA6/PA5 - and which may have "tormented" those usually pristine outputs...  (i.e. 99.9% of the time issue is the user - not the IC...)