2844 views|0 replies

2015

Posts

0

Resources
The OP
 

【DSP】TMS320F28035 ADC routine (ePWM+interrupt) [Copy link]

#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; //Map ADC interrupt EDIS; InitAdc(); PieCtrlRegs.PIEIER1.bit.INTx1 = 1; //Enable PIE level INT1.1 interrupt IER |= M_INT1; //Enable CPU level INT1 interrupt EINT; //Enable total interrupt ConversionCount = 0; EALLOW; AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Generate EOC one ADC clock cycle before conversion is completed AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enable ADCINT1 AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Turn off continuous mode AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //Map ADCINT1 to EOC1 AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //Map ADCINA0 to channel 0 AdcRegs.ADCSOC1CTL.bit.CHSEL = 1; //Map ADCINA1 to channel 1 AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //ePWM1A triggers SOC0 AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //ePWM1A triggers SOC1 AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //Set window sampling times AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //Set window sampling times EDIS; //Haven’t started studying ePWM EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on group A EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from CPMA on upcount EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event EPwm1Regs.CMPA.half.CMPA = 0x0080; // Set compare A value EPwm1Regs.TBPRD = 0xFFFF; // Set period for ePWM1 EPwm1Regs.TBCTL.bit.CTRMODE = 0; // count up and start 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; //Clear EOC1 signal (ADCINT1) PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; //Write 1 to clear 0, write 0 is invalid }


This post is from DSP and ARM Processors
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list