#include "DSP28X_Project.h"
#include"SCI.h"
unsigned char data=0;
unsigned int num=0;
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadEnd;
extern Uint16 RamfuncsRunStart;
interrupt void key_on(void); //按键的中断函数
void GPIO_inter_init()
{
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; //除能上拉电阻
GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0; //GPIO12
GpioCtrlRegs.GPADIR.bit.GPIO12 = 0; //输入
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 2; // 6 samples
GpioCtrlRegs.GPACTRL.bit.QUALPRD1 = 0xff;//采样周期为510*Tsysclk,窗口宽度为5*510*Tsysclk=2550/60M=42.5us
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 12; //GPIO12作为xint1的中断源
EDIS;
XIntruptRegs.XINT1CR.bit.POLARITY = 1; //上升沿触发中断
XIntruptRegs.XINT1CR.bit.ENABLE = 1; //外中断1使能
}
void Systeminit()
{
/***************************************************************************************
* EINT 使能中断, * 清除中断的标志位* 初始化中断向量表
**************************************************************************************/
InitSysCtrl();
DINT; //关闭所有的中断
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl();
InitPieVectTable();
//InitGpio(); //将GPIO的初始化省略掉
/**********************************************************************************
* 初始化SCI端口
**********************************************************************************/
InitSciaGpio();
/*********************************************************************************
* 将相应的代码拷贝到RAM中运行
**********************************************************************************/
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
InitFlash();
/*********************************************************************************
* 终端的重新映射
**********************************************************************************/
EALLOW; // This is needed to write to EALLOW protected registers
//PieVectTable.SCIRXINTA = &sciaRxFifoIsr;
PieVectTable.XINT1= &key_on;
EDIS; // This is needed to disable write to EALLOW protected registers
/*********************************************************************************
* SCI模块的初始化,与中断的初始化
**********************************************************************************/
SCIinit();
}
void main(void)
{
Systeminit(); //系统中各个模块的初始化,包括液晶的初始化
EALLOW;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, INT1
PieCtrlRegs.PIEIER1.bit.INTx4 = 1; //使能int1.4
IER |= M_INT9; // Enable USART INT
IER |= M_INT1;//使能int1
EDIS;
EINT;
//ERTM; // Enable Global realtime interrupt DBGM
GPIO_inter_init();
uart_sendingstring("hello liuming");
while(1)
{
if(data==1)
{
data=0;
scia_xmit(num);
}
}
}
interrupt void key_on(void)
{
data=1;
num++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
} |