#include "DSP28x_Project.h"
interrupt void adc_isr(void)
Uint16 ConversionCount
Uint16 Voltage1[10]
Uint16 Voltage2[10]
main()
{
InitSysCtrl()
DINT
InitPieCtrl()
IER = 0x0000
IFR = 0x0000
InitPieVectTable()
EALLOW
PieVectTable.ADCINT1 = &adc_isr
EDIS
InitAdc()
PieCtrlRegs.PIEIER1.bit.INTx1 = 1
IER |= M_INT1
EINT
ConversionCount = 0
EALLOW
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1
AdcRegs.INTSEL1N2.bit.INT1E = 1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0
AdcRegs.INTSEL1N2.bit.INT1SEL = 1
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 1
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6
EDIS
//还没开始研究ePWM
EPwm1Regs.ETSEL.bit.SOCAEN = 1
EPwm1Regs.ETSEL.bit.SOCASEL = 4
EPwm1Regs.ETPS.bit.SOCAPRD = 1
EPwm1Regs.CMPA.half.CMPA = 0x0080
EPwm1Regs.TBPRD = 0xFFFF
EPwm1Regs.TBCTL.bit.CTRMODE = 0
for(
{
}
}
interrupt void adc_isr(void)
{
Voltage1[ConversionCount] = AdcResult.ADCRESULT0
Voltage2[ConversionCount] = AdcResult.ADCRESULT1
if(ConversionCount == 9)
{
ConversionCount = 0
}
else ConversionCount++
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1
}