一種CSR電源控制系統(tǒng)設(shè)計與實現(xiàn)
PDCON = 0x1b;
PDCON = 0x14;
SPICON = 0x06;
SPITCON = 0x28;
ACLK = 9;
/* Set up Aux interrupt */
AIE=0x40;
EAI=1 ;
/* Setup ADC */
PDCON =0x0f7;
ADMUX=0x78;
ADCON0=0x00;
ADCON2=decimation 0xff;
ADCON3=(decimation 》8)0x07;
ADCON1=0x41;
AI=CLEAR;
SSCON=0x00;
SSCON=0xDB;
}
void dacout (unsigned int val) file://DAC輸出
{
Sync = SET;
Sync = CLEAR;
SPIDATA = 0;
SPIDATA = (char)(val》8 0x00ff);
SPIDATA = (char)(val 0x00ff);;
}
serial () interrupt 4 using 2 { file://寄存器組2用于中斷
unsigned char c,i;
if (RI) { // 如果接收器產(chǎn)生中斷
c = SBUF; file://讀數(shù)據(jù)
RI = 0; file://清除中斷請求標(biāo)志位
if(!(cmd_err==0cmd_finish==1addr_ok==1)){
switch (c) { file://處理數(shù)據(jù)
··· ···}
ADCcmd_proc() interrupt 6 using 3 file://ADC命令處理
{
unsigned long sum;
sum = ((unsigned long int)SUMR3 《 24)
+ ((unsigned long int)SUMR2 《 16)
+ ((unsigned long int)SUMR1 《 8)
+ (unsigned long int)SUMR0;
adcsum[adcin_p]=(float)(sum*LSB);
adcin_p++;
adcin_p=adcin_p7;
AI=CLEAR;
SSCON=0x00;
SSCON=0xDB; file://acc shift enable, accum 16x, right shift 4
}
4 結(jié)語
美國TI公司的帶24位A/D轉(zhuǎn)換的51內(nèi)核混合信號處理器MSC1210具有很高的性能、很高的集成度、很大的靈活性。帶可編程增益放大的24位A/D轉(zhuǎn)換器可以實現(xiàn)非常高精度的模數(shù)轉(zhuǎn)換。經(jīng)過幾個月的運行表明,該電源控制系統(tǒng)工作穩(wěn)定,較好地完成了系統(tǒng)的實時監(jiān)控和顯示任務(wù)。
評論