TMS320F2835的GPIO问题

TMS320F2835的GPIO问题

此问题已被解答
All Replies
  • 秀才203分

    1. 我连续两次GPIO的操作,经常会出现前面一次的无法操作,只有后面的才可以用

    2. 我再使用GPIO8的时候,在初始化GPIO8如下:

          GpioDataRegs.GPADAT.bit.GPIO8 = 1;
         GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0;
         GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0;
         GpioCtrlRegs.GPADIR.bit.GPIO8 = 1;
    并不能让GPIO8为高电平,  需要再次操作一次才可以让GPIO8为高电平,操作如下:
          GpioDataRegs.GPADAT.bit.GPIO8 = 1;
         GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0;
         GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0;
         GpioCtrlRegs.GPADIR.bit.GPIO8 = 1;
         GpioDataRegs.GPADAT.bit.GPIO8 = 1; 
    请问GPIO8是有什么特殊的地方吗?
  • 探花17936分

    您试下:

         GpioDataRegs.GPASET.bit.GPIO8 = 1;
         GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0;
         GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0;
         GpioCtrlRegs.GPADIR.bit.GPIO8 = 1;

  • 秀才203分

    GPACTRL 0x00000000 GPIO A Control Register (GPIO0 to 31) [Memory Mapped]
    GPAQSEL1 0x00000000 GPIO A Qualifier Select 1 Register (GPIO0 to 15) [Memory Mapped]
    GPAQSEL2 0x30000000 GPIO A Qualifier Select 2 Register (GPIO16 to 31) [Memory Mapped]
    GPAMUX1 0x00555555 GPIO A MUX 1 Register (GPIO0 to 15) [Memory Mapped]
    GPAMUX2 0x50000000 GPIO A MUX 2 Register (GPIO16 to 31) [Memory Mapped]
    GPADIR 0x3FF7E000 GPIO A Direction Register (GPIO0 to 31) [Memory Mapped]
    GPAPUD 0x00000FFF GPIO A Pull Up Disable Register (GPIO0 to 31) [Memory Mapped]
    GPBCTRL 0x00000000 GPIO B Control Register (GPIO32 to 44) [Memory Mapped]
    GPBQSEL1 0x00000000 GPIO B Qualifier Select 1 Register (GPIO32 to 44) [Memory Mapped]
    GPBMUX1 0x00050000 GPIO B MUX 1 Register (GPIO32 to 44) [Memory Mapped]
    GPBDIR 0x00001C83 GPIO B Direction Register (GPIO32 to 44) [Memory Mapped]
    GPBPUD 0x00000300 GPIO B Pull Up Disable Register (GPIO32 to 44) [Memory Mapped]
    AIOMUX1 0xAAAAAAAA Analog I/O MUX1 Register [Memory Mapped]
    AIODIR 0x00000000 Analog I/O Direction Register [Memory Mapped]
    GPADAT 0xC0003AAA GPIO A Data Register (GPIO0 to 31) [Memory Mapped]
    GPASET 0x00000000 GPIO A Data Set Register (GPIO0 to 31) [Memory Mapped]
    GPACLEAR 0x00000000 GPIO A Data Clear Register (GPIO0 to 31) [Memory Mapped]
    GPATOGGLE 0x00000000 GPIO A Data Toggle Register (GPIO0 to 31) [Memory Mapped]
    GPBDAT 0x0000067D GPIO B Data Register (GPIO32 to 44) [Memory Mapped]
    GPBSET 0x00000000 GPIO B Data Set Register (GPIO32 to 44) [Memory Mapped]
    GPBCLEAR 0x00000000 GPIO B Data Clear Register (GPIO32 to 44) [Memory Mapped]
    GPBTOGGLE 0x00000000 GPIO B Data Toggle Register (GPIO32 to 44) [Memory Mapped]
    AIODAT 0x00000000 Analog I/O Data Register [Memory Mapped]
    AIOSET 0x00000000 Analog I/O Data Set Register [Memory Mapped]
    AIOCLEAR 0x00000000 Analog I/O Data Clear Register [Memory Mapped]
    AIOTOGGLE 0x00000000 Analog I/O Data Toggle Register [Memory Mapped]
    GPIOXINT1SEL 0x0000 XINT1 GPIO Input Select Register (GPIO0 to 31) [Memory Mapped]
    GPIOXINT2SEL 0x0000 XINT2 GPIO Input Select Register (GPIO0 to 31) [Memory Mapped]
    GPIOXINT3SEL 0x0000 XINT3 GPIO Input Select Register (GPIO0 to 31) [Memory Mapped]
    GPIOLPMSEL 0x00000000 LPM GPIO Select Register (GPIO0 to 31) [Memory Mapped]

    目前上面是我的GPIO配置结果,

    void SetGpioLevel(unsigned int pin, unsigned int data)
    {

    if (pin < 32)
    {
    if (data > 0)
    {
    //GpioDataRegs.GPADAT.all |= (1 << pin);
    GpioDataRegs.GPASET.all |= (1 << pin);
    }
    else
    {
    //GpioDataRegs.GPADAT.all &= ~(1 << pin);
    GpioDataRegs.GPACLEAR.all |= (1 << pin);
    }
    }
    else if (pin < 64)
    {
    pin = pin-32;
    if (data > 0)
    {
    //GpioDataRegs.GPBDAT.all |= (1 << pin);
    GpioDataRegs.GPBSET.all |= (1 << pin);
    }
    else
    {
            //GpioDataRegs.GPBDAT.all &= ~(1 << pin);
              GpioDataRegs.GPBCLEAR.all |= (1 << pin);
         }
    }

    asm(" NOP");
    asm(" NOP");
    asm(" NOP");

    }

    使用这个函数进行控制

    SetGpioLevel(LedStatusGpioPin[i], 1);

    volatile Uint16 LedStatusGpioPin[] = { USER_GPIO42,
    USER_GPIO32,
    USER_GPIO21,
    USER_GPIO13,
    USER_GPIO16,
    USER_GPIO17,
    USER_GPIO29 };

    其中USER_GPIO42   USER_GPIO32  USER_GPIO13可以控制,   USER_GPIO21和GPIO16确不受控, 我想输入为高电平, GPADAT 里面确实也为0,不知道为什么

  • 进士3770分

    你可以尝试把1<<pin改成(Uint32)1<<pin

    LiveSine

  • 秀才203分

    非常感谢。测试这样是可以的,应该默认为U16了,   修改为U32就好了