F28027在CCS中的ADC模块的程序在调试时改不了寄存器的值,这是为什么呢??应该已经使能ADC模块了的。附源程序:
#include "DSP28x_Project.h" interrupt void tim0_isr(void);interrupt void ADC_convered(void);Uint16 ADCINA0_Voltage_sum = 0;Uint16 ADCINA1_Voltage_sum = 0;Uint16 ADCINA2_Voltage_sum = 0;Uint16 ADCINA0_Voltage = 0; Uint16 ADCINA1_Voltage = 0;Uint16 ADCINA2_Voltage = 0;char convered_count = 0;void main(void) { InitSysCtrl(); InitGpio(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); InitAdc(); EALLOW; AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 0; //SOC0、SOC1单一采样 AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2 = 0; //SOC2、SOC3单一采样 AdcRegs.ADCSOC0CTL.bit.CHSEL=0; //SOC通道选择 AdcRegs.ADCSOC1CTL.bit.CHSEL=1; AdcRegs.ADCSOC2CTL.bit.CHSEL=2; AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //采样时间 AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; AdcRegs.ADCSOC2CTL.bit.ACQPS = 6; AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //soc触发选择,TIM0 AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //结果存入寄存器才产生中断 PieVectTable.ADCINT1 = &ADC_convered; AdcRegs.INTSEL1N2.bit.INT1SEL = 2; //中断线1选择soc2 AdcRegs.INTSEL1N2.bit.INT1CONT = 0; AdcRegs.INTSEL1N2.bit.INT1E = 1; //中断使能 PieCtrlRegs.PIEIER1.bit.INTx1 = 1; //使能int1.1 EDIS;/****************设置定时器,用以触发ADC*****************/ CpuTimer0Regs.TPR.bit.TDDR = 59; CpuTimer0Regs.TPRH.bit.TDDRH = 0; //对输入时钟60分频,60M/60=1M CpuTimer0Regs.PRD.all = 500000;//定时0.5s CpuTimer0Regs.TCR.bit.TRB = 1; //reload CpuTimer0Regs.TCR.bit.TIE = 1; //使能中断 CpuTimer0Regs.TCR.bit.TSS = 0; //开始计数 EALLOW; PieVectTable.TINT0 = &tim0_isr; PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //使能PIE PieCtrlRegs.PIEIER1.bit.INTx7 = 1; //使能int1.7 IER |= 0x0001;//使能GROUP1 EINT; EDIS; } interrupt void ADC_convered(void) { //LED_toggle(LED2); ADCINA0_Voltage_sum += AdcResult.ADCRESULT0; ADCINA1_Voltage_sum += AdcResult.ADCRESULT1; ADCINA2_Voltage_sum += AdcResult.ADCRESULT2; AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; convered_count++; /*********转换16次,取平均值*********/ if(convered_count > 15) { ADCINA0_Voltage = ADCINA0_Voltage_sum >> 4;//相当于除以16 ADCINA1_Voltage = ADCINA1_Voltage_sum >> 4; ADCINA2_Voltage = ADCINA2_Voltage_sum >> 4; ADCINA0_Voltage_sum = 0; ADCINA1_Voltage_sum = 0; ADCINA2_Voltage_sum = 0; convered_count = 0; } } interrupt void tim0_isr(void) { PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; } //=========================================================================== // No more. //===========================================================================
此帖出自
小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>