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.

C6748 GPIO程序

Other Parts Discussed in Thread: TMS320C6748

如下图所示,调试例程里的GPIO程序,109端口对应开发板上的第二个led灯,请问如果要控制另一个灯,怎么找到这个灯的端口号?

  • 查看开发板的硬件原理图,或者硬件手册,另外一个灯与那个pin相连。

  • 再看看GPIODirModeSet这个函数的定义

  • 查看手册,已知led4是GPIO bank6 pin12的,它的pin number 是109,而led3是GPIO bank6 pin13 的,怎么知道它的pin number呢?

  • “led4是GPIO bank6 pin12的,它的pin number 是109”

    对于这个pin number肯定会有定义的地方,看看手册说明或者该函数处的定义

  • 现在如果要定义GPIO bank6 pin13,以下的语句怎么修改,后面的两个数字修改可以参考什么呢

  • 这个地方的寄存器配置,可以参考的地方是技术手册247页

  • TMS320C6748 DSP
    Technical Reference Manual

    http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=spruh79&fileType=pdf

  • 看一下gpio.c里的函数说明和代码实现,就是一个bank 32个GPIO,从低bank往高排的。

    /**
    * \brief This function gets the direction of a pin which has been configured
    * as an input or an output pin.
    *
    * \param baseAdd The memory address of the GPIO instance being used.
    * \param pinNumber The serial number of the GPIO pin.
    * The 144 GPIO pins have serial numbers from 1 to 144.
    *
    * \return This returns one of the following two values:
    * 1> GPIO_DIR_INPUT, if the pin is configured as an input pin.
    * 2> GPIO_DIR_OUTPUT, if the pin is configured as an output pin.

    unsigned int GPIODirModeGet(unsigned int baseAdd, unsigned int pinNumber)
    {
    unsigned int dir = GPIO_DIR_INPUT;
    unsigned int regNumber = 0;
    unsigned int pinOffset = 0;

    /*
    ** Each register contains settings for each pin of two banks. The 32 bits
    ** represent 16 pins each from the banks. Thus the register number must be
    ** calculated based on 32 pins boundary.
    */

    regNumber = (pinNumber - 1)/32;

    /*
    ** In every register the least significant bits starts with a GPIO number on
    ** a boundary of 32. Thus the pin offset must be calculated based on 32
    ** pins boundary. Ex: 'pinNumber' of 1 corresponds to bit 0 in
    ** 'register_name01'.
    */

    pinOffset = (pinNumber - 1) % 32;

    dir = (HWREG(baseAdd + GPIO_DIR(regNumber)) & (1 << pinOffset));

    return (dir >> pinOffset);

  • I think you can get your answer by referring to page 848 in TMR. Table 19-1 may give you a little help.