Easy2812开发板A/D转换,RS232与PC通信例子:
#include "DSP28_Device.h"
unsigned int Sci_VarRx[100];
unsigned int i,j;
volatile unsigned int Send_Flag=0;
float adclo=0.0; //0位调整
void main(void)
{
/*初始化系统*/
InitSysCtrl();
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;
/*初始化PIE中断*/
InitPieCtrl();
/*初始化PIE中断矢量表*/
InitPieVectTable();
/*初始化SCIA寄存器*/
InitSci();
InitAdc();
/*设置中断服务程序入口地址*/
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TXAINT = &SCITXINTA_ISR;
PieVectTable.RXAINT = &SCIRXINTA_ISR;
PieVectTable.ADCINT = &ADCINT_ISR; ////中断向量表中的ADCINT中断指向AD中断函数
EDIS; // This is needed to disable write to EALLOW protected registers
/*开中断*/
IER |= M_INT1 | M_INT9;
while(AdcRegs.ADC_ST_FLAG.bit.SEQ1_BSY==0)//读排序器1的忙状态位,为0是空闲
{
AdcRegs.ADCTRL2.bit.SOC_SEQ1=1; //启动SEQ1开始转换
}
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
for(;;)
{
}
} |