This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hello all,
I configure the timer 1 on cpu1 and want when the TIMH:TIM decrements to zero the SOC0 triggered and ADC start converting of voltage. I write below program but my program does not entry into ISR and does not converting my voltage.
Any body can help me to find reason of this ?
My code is :
/* * main.c */ #include "F28x_Project.h" //////// // global variable //////// uint16_t adc0[100],adc1[100],adc2[100],adc3[100]; // result of adc conversion uint16_t i=0; //interrupt void CPU_TIMER1_ISR(void); void configuretimer1 (void); void configureADC (void); interrupt void adca1_isr (void); void main(void) { InitSysCtrl(); DINT; // disable global interrupt InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; PieVectTable.ADCA1_INT = &adca1_isr; EDIS; PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block IER |= M_INT1; //Enable group 1 interrupts EINT; ERTM; // Enable Global realtime interrupt DBGM PieCtrlRegs.PIEIER1.bit.INTx1 = 1; configureADC(); configuretimer1(); while(1); } void configuretimer1 (void) { //CpuTimer1Regs.TCR.bit.TIE = 1; // enable timer1 interrupt CpuTimer1Regs.TCR.bit.FREE = 1; // FREE:SOFT = 3 for free runs CpuTimer1Regs.TCR.bit.SOFT = 1; CpuTimer1Regs.TPRH.bit.TDDRH = 0; // TDDRH:TDDR = 9 ----> prescaler = 10 CpuTimer1Regs.TPR.bit.TDDR = 9; CpuTimer1Regs.PRD.all = 100; // 5000 nsec = 5usec CpuTimer1Regs.TCR.bit.TSS = 0; // start counting } void configureADC (void) { EALLOW; AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 //AdcbRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 //AdccRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 //AdcdRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //AdcSetMode(ADC_ADCC, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //AdcSetMode(ADC_ADCD, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion //AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion //AdccRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion //AdcdRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCA //AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCB //AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCC //AdcdRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCD DELAY_US(1000); //////////////////////delay for 1ms to allow ADC time to power up AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert ADCINA0 //AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert ADCINB0 //AdccRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert ADCINC0 //AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert ADCIND0 AdcaRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec //AdcbRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec //AdccRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec //AdcdRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 2; //AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 2; //AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 2; //AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 2; AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;//end of SOC0 will set ADCINT1 flag //AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 3;//end of SOC3 will set INT1 flag //AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 3;//end of SOC3 will set INT1 flag //AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 3;//end of SOC3 will set INT1 flag AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared //AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared //AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared //AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared EDIS; } interrupt void adca1_isr (void) { asm(" ESTOP0"); if (i <= 99){ adc0[i] = AdcaResultRegs.ADCRESULT0; adc1[i] = AdcbResultRegs.ADCRESULT0; adc2[i] = AdccResultRegs.ADCRESULT0; adc3[i] = AdcdResultRegs.ADCRESULT0; i++; } PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; }
Thank you very much for helping.
The attached should work. I didn't change much in your file - you were almost there. In principle, you should always configure your peripherals first, then enable your interrupts, then start whatever timer you want to use for the trigger. In that order.
You have to enable the CPU timer TIE bit to get the ADC trigger to go even if you don't want to interrupt from the timer. I also added a line at the end of your ISR to reset the ADC interrupt flag, otherwise it will run only once.
Hope this helps.
Regards,
Richard
#include "F28x_Project.h" uint16_t adc0[100],adc1[100],adc2[100],adc3[100]; // result of adc conversion uint16_t i=0; //interrupt void CPU_TIMER1_ISR(void); void configuretimer1 (void); void configureADC (void); interrupt void adca1_isr (void); void main(void) { InitSysCtrl(); DINT; // disable global interrupt InitPieCtrl(); // IER = 0x0000; // IFR = 0x0000; InitPieVectTable(); configureADC(); configuretimer1(); EALLOW; PieVectTable.ADCA1_INT = &adca1_isr; EDIS; PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block IER |= M_INT1; //Enable group 1 interrupts EINT; ERTM; // Enable Global realtime interrupt DBGM PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; PieCtrlRegs.PIEIER1.bit.INTx1 = 1; while(1); } void configuretimer1 (void) { CpuTimer1Regs.TCR.bit.TIE = 1; // enable timer1 interrupt CpuTimer1Regs.TCR.bit.FREE = 1; // FREE:SOFT = 3 for free runs CpuTimer1Regs.TCR.bit.SOFT = 1; CpuTimer1Regs.TPRH.bit.TDDRH = 0; // TDDRH:TDDR = 9 ----> prescaler = 10 CpuTimer1Regs.TPR.bit.TDDR = 9; CpuTimer1Regs.PRD.all = 100; // 5000 nsec = 5usec CpuTimer1Regs.TCR.bit.TSS = 0; // start counting } void configureADC (void) { EALLOW; AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 //AdcbRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 //AdccRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 //AdcdRegs.ADCCTL2.bit.PRESCALE = 6; // ADCCLK = input clock/4 AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //AdcSetMode(ADC_ADCC, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //AdcSetMode(ADC_ADCD, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion //AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion //AdccRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion //AdcdRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCA //AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCB //AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCC //AdcdRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power on ADCD DELAY_US(1000); //////////////////////delay for 1ms to allow ADC time to power up AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; // SOC0 will convert ADCINA0 //AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert ADCINB0 //AdccRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert ADCINC0 //AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert ADCIND0 AdcaRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec //AdcbRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec //AdccRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec //AdcdRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 2; //AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 2; //AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 2; //AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 2; AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;//end of SOC0 will set ADCINT1 flag //AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 3;//end of SOC3 will set INT1 flag //AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 3;//end of SOC3 will set INT1 flag //AdcdRegs.ADCINTSEL1N2.bit.INT1SEL = 3;//end of SOC3 will set INT1 flag AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag //AdcdRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared //AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared //AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared //AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared EDIS; } interrupt void adca1_isr (void) { asm(" ESTOP0"); if (i <= 99){ adc0[i] = AdcaResultRegs.ADCRESULT0; adc1[i] = AdcbResultRegs.ADCRESULT0; adc2[i] = AdccResultRegs.ADCRESULT0; adc3[i] = AdcdResultRegs.ADCRESULT0; i++; } PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; }