这是我的程序:
#include \"DSP28_Device.h\"
#include \"DSP28_Globalprototypes.h\"
// Prototype statements for functions found within this file.
// interrupt void ISRTimer2(void);
void delay_loop(void);
void Gpio_select(void);
unsigned int var1 = 0;
unsigned int var2 = 0;
unsigned int var3 = 0;
unsigned int var4 = 0;
unsigned int var5 = 0;
void main(void)
{
InitSysCtrl();
// Disable and clear all CPU interrupts:
DINT;
IER = 0x0000;
IFR = 0x0000;
// Initialize Pie Control Registers To Default State:
InitPieCtrl();
InitPieVectTable();
// Run GPIO test
var1= 0x00; // sets GPIO Muxs as I/Os
var2= 0x00; // sets GPIO DIR as inputs
var3= 0x00; // sets the Input qualifier values
Gpio_select();
// Toggle I/Os using DATA register for ever
GpioDataRegs.GPASET.all=0;
while(1)
{var2=GpioDataRegs.GPADAT.all;}
var3= 0x0000;
}
void Gpio_select(void)
{
EALLOW;
GpioMuxRegs.GPAMUX.all=var1;
GpioMuxRegs.GPBMUX.all=var1;
GpioMuxRegs.GPDMUX.all=var1;
GpioMuxRegs.GPFMUX.all=var1;
GpioMuxRegs.GPEMUX.all=var1;
GpioMuxRegs.GPGMUX.all=var1;
GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as input
GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as input
GpioMuxRegs.GPDDIR.all=var2;
GpioMuxRegs.GPEDIR.all=var2;
GpioMuxRegs.GPFDIR.all=var2;
GpioMuxRegs.GPGDIR.all=var2;
GpioMuxRegs.GPAQUAL.all=var3;
GpioMuxRegs.GPBQUAL.all=var3;
GpioMuxRegs.GPDQUAL.all=var3;
GpioMuxRegs.GPEQUAL.all=var3;
EDIS;
}
不知道为什么,GpioDataRegs.GPADAT.all读不出IO的电平,总是读为0xFFFC
本帖最后由 dontium 于 2015-1-23 13:38 编辑
你这程序根本看不出啥,都作了宏定义了
gpio就要先设置一下是作io口用;
然后设置方向,不复杂的
本帖最后由 dontium 于 2015-1-23 13:38 编辑
var2= 0x00; // sets GPIO DIR as inputs
你写了这个是方向变量,然后后面的死循环里
你又把读出的值给方向变量干啥,(猜是读值)
程序不全,就不瞎说了
竟然有个死循环,死循环后面竟然还有语句。这程序完全乱套。