[求助] 28335 GPIO71~79问题

jetlin1992   2016-5-23 22:01 楼主
想用GPIO输出高低电平,程序如下
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"
//#ifdef TOFLASH
//extern void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
//extern Uint16 RamfuncsLoadStart;
//extern Uint16 RamfuncsLoadEnd;
//extern Uint16 RamfuncsRunStart;
//#endif
void Sci_initial(void);
void scia_xmit(int a);
void scia_msg(char *msg);
MMC0326.zip (339.26 KB)
(下载次数: 13, 2016-5-23 22:01 上传)


MMC0326.zip (339.26 KB)
(下载次数: 13, 2016-5-23 22:01 上传)


unsigned int*DAOUT1=(unsigned int*)(0x00200000);
int ax;
int main(void) {
Uint16 ReceivedChar;
char *msg;
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
//#ifdef TOFLASH
// MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// InitFlash();
//#endif
//InitXintf16Gpio();
//InitXintf();
// Sci_initial();
InitGpio();
GpioDataRegs.GPCCLEAR.all=0xffffffff;
GpioDataRegs.GPCSET.all=0xffffffff;
GpioDataRegs.GPCDAT.all=0x00006789;
//GpioDataRegs.GPCSET.all=0x0000ffff;
for(;;)
{
//ax=0;
msg = "\r\nEnter a character: \0";
scib_msg(msg);
// ax=&DAOUT1;
}
return 0;
}

InitGpio();在另一个c文件里面
void InitGpio(void)
{
EALLOW;

// Each GPIO pin can be:
// a) a GPIO input/output
// b) peripheral function 1
// c) peripheral function 2
// d) peripheral function 3
// By default, all are GPIO Inputs
GpioCtrlRegs.GPAMUX1.all = 0x0000; // GPIO functionality GPIO0-GPIO15
GpioCtrlRegs.GPAMUX2.all = 0x0000; // GPIO functionality GPIO16-GPIO31
GpioCtrlRegs.GPBMUX1.all = 0x0000; // GPIO functionality GPIO32-GPIO39
GpioCtrlRegs.GPBMUX2.all = 0x0000; // GPIO functionality GPIO48-GPIO63
GpioCtrlRegs.GPCMUX1.all = 0x0000; // GPIO functionality GPIO64-GPIO79
GpioCtrlRegs.GPCMUX2.all = 0x0000; // GPIO functionality GPIO80-GPIO95
GpioCtrlRegs.GPADIR.all = 0x0000; // GPIO0-GPIO31 are inputs
GpioCtrlRegs.GPBDIR.all = 0x0000; // GPIO32-GPIO63 are inputs
GpioCtrlRegs.GPCDIR.all = 0xffff; // GPI064-GPIO95 are inputs
// Each input can have different qualification
// a) input synchronized to SYSCLKOUT
// b) input qualified by a sampling window
// c) input sent asynchronously (valid for peripheral inputs only)
GpioCtrlRegs.GPAQSEL1.all = 0x0000; // GPIO0-GPIO15 Synch to SYSCLKOUT
GpioCtrlRegs.GPAQSEL2.all = 0x0000; // GPIO16-GPIO31 Synch to SYSCLKOUT
GpioCtrlRegs.GPBQSEL1.all = 0x0000; // GPIO32-GPIO39 Synch to SYSCLKOUT
GpioCtrlRegs.GPBQSEL2.all = 0x0000; // GPIO48-GPIO63 Synch to SYSCLKOUT
// Pull-ups can be enabled or disabled.
GpioCtrlRegs.GPAPUD.all = 0x5555; // Pullup's enabled GPIO0-GPIO31
GpioCtrlRegs.GPBPUD.all = 0x0000; // Pullup's enabled GPIO32-GPIO63
GpioCtrlRegs.GPCPUD.all = 0x0000; // Pullup's enabled GPIO64-GPIO79
//GpioCtrlRegs.GPAPUD.all = 0xFFFF; // Pullup's disabled GPIO0-GPIO31
//GpioCtrlRegs.GPBPUD.all = 0xFFFF; // Pullup's disabled GPIO32-GPIO34
//GpioCtrlRegs.GPCPUD.all = 0xFFFF; // Pullup's disabled GPIO64-GPIO79
EDIS;
}
QQ截图20160523215517.png

执行置位时可以成功使GPCDAT改变
直接对GPCDAT赋值时只能改变最低八位

QQ截图20160523215524.png

回复评论 (1)

关于DSP C6000培训,可以看下我的签名
创龙DSP开发培训,时间为2016年7月18日,http://51dsp.net/forum.php?mod=viewthread&tid=939
点赞  2016-5-25 17:53
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复