首先附上程序 2812通过CPLD扩展了8路的LED灯,程序运行没问题,键盘还没有接的所以可以认为是全0,取反之后应该是1,所以全亮。可是当我将while循环中的LED=~KEYSCAN改成LED=0x80,8个灯还是全亮。
请问我哪里错了??
#include "DSP281x_Device.h"
#include "example_nonBIOS.h"
#define LED (*((unsigned int *)0x4400))
#define KEY (*((unsigned int *)0x5800))
Uint16 KEYSCAN = 0;
void User_Init(void);
/**********************************************************************
* Function: main()
*
* Description: Main function for F281x example.
**********************************************************************/
void main(void)
{
/*** CPU Initialization ***/
InitSysCtrl(); // Initialize the CPU (FILE: SysCtrl.c)
InitXintf(); // Initialize the external memory interface (FILE: Xintf.c)
/*** Initialize the SYSTEM ***/
User_Init();
SetDBGIER(IER); // Configure the DBGIER for realtime debug
EINT; // Enable global interrupts and realtime debug
asm(" CLRC INTM, DBGM");
/*** Main Cycle ***/
while(1)
{
KEYSCAN = KEY;
LED =~ KEYSCAN;;//取反运算符~
}// End of while(1)
}// End of main()
void User_Init(void)
{
/*** Initialize the interrupts ***/
//InitXintrupt(); //Initialize the external interrupts(File: Xintrupt.c)
IFR &= 0x0000; //Clear all interrupt flag
}// End of Init_main()
|