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.

F28M35 管脚配置的问题



您好:

这是uart的管脚配置,我想请教下这5句分别实现了什么配置。我总是觉得第2句和3、4两句是实现同样的配置。

     SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPinConfigure(GPIO_PE4_U0RX);
    GPIOPinConfigure(GPIO_PE5_U0TX);
    GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5, GPIO_PIN_TYPE_STD_WPU);

另外请教下JTAG口和时钟相关的管脚是否还需要配置?

谢谢您的指导!

  • 楼主,问题一:

    GPIOPinTypeUART(unsigned long ulPort, unsigned char ucPins)
    {
        // Check the arguments.
        ASSERT(GPIOBaseValid(ulPort));

        // Make the pin(s) be peripheral controlled.
        GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);

        // Set the pad(s) for standard push-pull operation.
        GPIOPadConfigSet(ulPort, ucPins, GPIO_PIN_TYPE_STD_WPU);
    }

    GPIOPinConfigure(unsigned long ulPinConfig)
    {
        unsigned long ulBase, ulShift, ulAlternatePort;

        // Check the argument.
        ASSERT(((ulPinConfig >> 16) & 0xff) < 9);
        ASSERT(((ulPinConfig >> 8) & 0xe3) == 0);

        // Extract the base address index from the input value.
        ulBase = (ulPinConfig >> 16) & 0xff;

        // Get the base address of the GPIO module, selecting either the APB or the
        // AHB aperture as appropriate.
        if(HWREG(SYSCTL_GPIOHBCTL) & (1 << ulBase))
        {
            ulBase = g_pulGPIOBaseAddrs[(ulBase << 1) + 1];
        }
        else
        {
            ulBase = g_pulGPIOBaseAddrs[ulBase << 1];
        }

        // Extract the shift from the input value.
        ulShift = (ulPinConfig >> 8) & 0xff;

        // Extract Alternate port information
        ulAlternatePort = (ulPinConfig >> 4) & 0xF;

        if(ulAlternatePort != 0)
        {
            HWREG(ulBase + GPIO_O_APSEL) |= 1 << (ulShift>>2);
        }
        else
        {
            HWREG(ulBase + GPIO_O_APSEL) &= ~(1 << (ulShift>>2));
        }

        // Write the requested pin muxing value for this GPIO pin.
        HWREG(ulBase + GPIO_O_PCTL) = ((HWREG(ulBase + GPIO_O_PCTL) &
                                        ~(0xf << ulShift)) |
                                       ((ulPinConfig & 0xf) << ulShift));

    }

    这是驱动库中这两个函数的源码,源码中看GPIOPinTypeUART指数设置了映射到UART口的GPIO的输入输出,以及上拉推挽模式,

    而GPIOPinConfigure函数则是真正的设置GPIO Muxing,并且在这之前会做一系列检测。

     

    问题二:

    Jtag和时钟相关的管脚一般不需要配置,除非你需要复用Jtag引脚。