TI中文支持网
TI专业的中文技术问题咨询交流网站

TMS320F28035,PGIO脚不受控

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");

}

使用这个函数进行控制

int i;  

for(i = 0; i < 7; i++)

{

           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,不知道为什么,    初始化的时候已经全部配置成  上拉、输出、GPIO功能,但是无作用。

user3735001:

回复 Seven Han:

根据社区会员提供的方法:可以尝试把1<<pin改成(Uint32)1<<pin

解决了问题. 非常感谢

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");

}

使用这个函数进行控制

int i;  

for(i = 0; i < 7; i++)

{

           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,不知道为什么,    初始化的时候已经全部配置成  上拉、输出、GPIO功能,但是无作用。

user3735001:

回复 Seven Han:

根据社区会员提供的方法:可以尝试把1<<pin改成(Uint32)1<<pin 已经把问题解决了。

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28035,PGIO脚不受控
分享到: 更多 (0)