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,
I am new to MCU F28379D. I tried the Lab6 of C28x workshop module where only one ADC conversion is done triggered by EPWM2SOCA. But when I am trying to implement the same for multiple ADC from multiple modules I am unable to do so. I have gone thorugh Technical Reference Manual and made changes in CHSEL, TRIGSEL, ACQPS for both Adca and Adcb. But I feel the interrupt configuration should be changed according which is not mentioned. I have gone through the thread https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/750822 , but of no use as the mentioned tweaks have already been done.
Pleae find the Lab6 solution of C2000 one day workshop manual. I have modified the Adc.c file of that project keeping the rest of the code intact.
I am attaching the code for your kind perusal :
/********************************************************************** * File: Adc.c -- Solution File * Devices: TMS320F28x7x * Author: C2000 Technical Training, Texas Instruments **********************************************************************/ #include "Lab.h" // Main include file /********************************************************************** * Function: InitAdca() * * Description: Initializes ADC-A on the F28x7x **********************************************************************/ void InitAdca(void) { asm(" EALLOW"); // Enable EALLOW protected register access //--- Reset the ADC. This is good programming practice. DevCfgRegs.SOFTPRES13.bit.ADC_A = 1; // ADC is reset DevCfgRegs.SOFTPRES13.bit.ADC_A = 0; // ADC is released from reset DevCfgRegs.SOFTPRES13.bit.ADC_B = 1; // ADC is reset DevCfgRegs.SOFTPRES13.bit.ADC_B = 0; // ADC is released from reset //--- Configure the ADC base registers AdcaRegs.ADCCTL1.all = 0x0004; // Main ADC configuration AdcbRegs.ADCCTL1.all = 0x0004; // Main ADC configuration // bit 15-14 00: reserved // bit 13 0: ADCBSY, ADC busy, read-only // bit 12 0: reserved // bit 11-8 0's: ADCBSYCHN, ADC busy channel, read-only // bit 7 0: ADCPWDNZ, ADC power down, 0=powered down, 1=powered up // bit 6-3 0000: reserved // bit 2 1: INTPULSEPOS, INT pulse generation, 0=start of conversion, 1=end of conversion // bit 1-0 00: reserved AdcaRegs.ADCCTL2.all = 0x0006; // ADC clock configuration AdcbRegs.ADCCTL2.all = 0x0006; // ADC clock configuration // bit 15-8 0's: reserved // bit 7 0: SIGNALMODE, configured by AdcSetMode() below to get calibration correct // bit 6 0: RESOLUTION, configured by AdcSetMode() below to get calibration correct // bit 5-4 00: reserved // bit 3-0 0110: PRESCALE, ADC clock prescaler. 0110=CPUCLK/4 AdcaRegs.ADCBURSTCTL.all = 0x0000; AdcbRegs.ADCBURSTCTL.all = 0x0000; // bit 15 0: BURSTEN, 0=burst mode disabled, 1=burst mode enabled // bit 14-12 000: reserved // bit 11-8 0000: BURSTSIZE, 0=1 SOC converted (don't care) // bit 7-6 00: reserved // bit 5-0 000000: BURSTTRIGSEL, 00=software only (don't care) //--- Call AdcSetMode() to configure the resolution and signal mode. // This also performs the correct ADC calibration for the configured mode. AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //--- SOC0 configuration AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // Trigger using ePWM2-ADCSOCA AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; // Convert channel ADCINA0 (Ch. 0) AdcaRegs.ADCSOC0CTL.bit.ACQPS = 19; // Acquisition window set to (19+1)=20 cycles (100 ns with 200 MHz SYSCLK) AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 0; // No ADC interrupt triggers SOC0 (TRIGSEL field determines trigger) AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 0; // All SOCs handled in round-robin mode //--- ADCA1 interrupt configuration AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 1; // Interrupt pulses regardless of flag state AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable the interrupt in the ADC AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // EOC0 triggers the interrupt AdcbRegs.ADCINTSEL1N2.bit.INT1CONT = 1; // Interrupt pulses regardless of flag state AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable the interrupt in the ADC AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // EOC0 triggers the interrupt //--- Enable the ADC interrupt PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable ADCA1 interrupt in PIE group 1 PieCtrlRegs.PIEIER1.bit.INTx2 = 1; // Enable ADCB1 interrupt in PIE group 1 IER |= 0x0001; // Enable INT1 in IER to enable PIE group //--- Finish up AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC DelayUs(1000); // Wait 1 ms after power-up before using the ADC asm(" EDIS"); // Disable EALLOW protected register access } // end InitAdc() //--- end of file -----------------------------------------------------
You didn't configure any SOCs for ADC B in the code above. I only see configuration for SOC0 on ADC A.
You mentioned something about the interrupt configuration not being right--are you don't getting any interrupts? Not even for ADC A? Did you remember enable the interrupt in PIEIER and IER? Are interrupt enabled globally?
If you haven't done so already, you may want to look at some C2000Ware examples in addition to the workshop. They may give you some ideas.
Whitney
Dear Whitney,
Thanks for your response.
Sorry for the inconvenience. The modified code is attached herewith. However I would like to inform that the following mentioned code is working fine.
So the issue is resolved for now. Thanks once again.
/********************************************************************** * File: Adc.c -- Solution File * Devices: TMS320F28x7x * Author: C2000 Technical Training, Texas Instruments **********************************************************************/ #include "Lab.h" // Main include file /********************************************************************** * Function: InitAdca() * * Description: Initializes ADC-A on the F28x7x **********************************************************************/ void InitAdca(void) { asm(" EALLOW"); // Enable EALLOW protected register access //--- Reset the ADC. This is good programming practice. DevCfgRegs.SOFTPRES13.bit.ADC_A = 1; // ADC is reset DevCfgRegs.SOFTPRES13.bit.ADC_A = 0; // ADC is released from reset DevCfgRegs.SOFTPRES13.bit.ADC_B = 1; // ADC is reset DevCfgRegs.SOFTPRES13.bit.ADC_B = 0; // ADC is released from reset //--- Configure the ADC base registers AdcaRegs.ADCCTL1.all = 0x0004; // Main ADC configuration AdcbRegs.ADCCTL1.all = 0x0004; // Main ADC configuration // bit 15-14 00: reserved // bit 13 0: ADCBSY, ADC busy, read-only // bit 12 0: reserved // bit 11-8 0's: ADCBSYCHN, ADC busy channel, read-only // bit 7 0: ADCPWDNZ, ADC power down, 0=powered down, 1=powered up // bit 6-3 0000: reserved // bit 2 1: INTPULSEPOS, INT pulse generation, 0=start of conversion, 1=end of conversion // bit 1-0 00: reserved AdcaRegs.ADCCTL2.all = 0x0006; // ADC clock configuration AdcbRegs.ADCCTL2.all = 0x0006; // ADC clock configuration // bit 15-8 0's: reserved // bit 7 0: SIGNALMODE, configured by AdcSetMode() below to get calibration correct // bit 6 0: RESOLUTION, configured by AdcSetMode() below to get calibration correct // bit 5-4 00: reserved // bit 3-0 0110: PRESCALE, ADC clock prescaler. 0110=CPUCLK/4 AdcaRegs.ADCBURSTCTL.all = 0x0000; AdcbRegs.ADCBURSTCTL.all = 0x0000; // bit 15 0: BURSTEN, 0=burst mode disabled, 1=burst mode enabled // bit 14-12 000: reserved // bit 11-8 0000: BURSTSIZE, 0=1 SOC converted (don't care) // bit 7-6 00: reserved // bit 5-0 000000: BURSTTRIGSEL, 00=software only (don't care) //--- Call AdcSetMode() to configure the resolution and signal mode. // This also performs the correct ADC calibration for the configured mode. AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE); //--- SOC0 configuration AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // Trigger using ePWM2-ADCSOCA AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; // Convert channel ADCINA0 (Ch. 0) AdcaRegs.ADCSOC0CTL.bit.ACQPS = 19; // Acquisition window set to (19+1)=20 cycles (100 ns with 200 MHz SYSCLK) AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 0; // No ADC interrupt triggers SOC0 (TRIGSEL field determines trigger) AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 0; // All SOCs handled in round-robin mode AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // Trigger using ePWM2-ADCSOCA AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0; // Convert channel ADCINA0 (Ch. 0) AdcbRegs.ADCSOC0CTL.bit.ACQPS = 19; // Acquisition window set to (19+1)=20 cycles (100 ns with 200 MHz SYSCLK) AdcbRegs.ADCINTSOCSEL1.bit.SOC0 = 0; // No ADC interrupt triggers SOC0 (TRIGSEL field determines trigger) AdcbRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 0; // All SOCs handled in round-robin mode //--- ADCA1 interrupt configuration AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 1; // Interrupt pulses regardless of flag state AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // Enable the interrupt in the ADC AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // EOC0 triggers the interrupt //--- Enable the ADC interrupt PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable ADCA1 interrupt in PIE group 1 IER |= 0x0001; // Enable INT1 in IER to enable PIE group //--- Finish up AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up the ADC DelayUs(1000); // Wait 1 ms after power-up before using the ADC asm(" EDIS"); // Disable EALLOW protected register access } // end InitAdc() //--- end of file -----------------------------------------------------