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.

how to change the channel ADC? F28069

Other Parts Discussed in Thread: CONTROLSUITE, TMS320F28069

hi i am new to this MCU, I try to learn about it.


I have a simple question, I'm using an example of controlSUITE:

"adc_tempsensorconv" and by default it only uses the channel A5.

I would like to know how to configure a new channel and how to select correctly, thank you.

#include "DSP28x_Project.h" // DSP28x Headerfile

#define CONV_WAIT 1L //Micro-seconds to wait for ADC conversion. Longer than necessary.
extern void DSP28x_usDelay(Uint32 Count);

int16 value_adc;
int16 adc_sample[1024];
float adc_vol[1024];

void main() {
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2806x_SysCtrl.c file.
InitSysCtrl();

// Step 2. Initalize GPIO:
// Enable XCLOCKOUT to allow monitoring of oscillator 1
EALLOW;
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 3; //enable XCLOCKOUT through GPIO mux
SysCtrlRegs.XCLK.bit.XCLKOUTDIV = 2; //XCLOCKOUT = SYSCLK

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2806x_PieCtrl.c file.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in F2806x_DefaultIsr.c.
// This function is found in F2806x_PieVect.c.
InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:
// This function is found in F2806x_InitPeripherals.c
// InitPeripherals(); // Not required for this example

// Configure the ADC:
// Initialize the ADC
InitAdc();
AdcOffsetSelfCal();

EALLOW;
AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1; //Enable non-overlap mode
// AdcRegs.ADCCTL1.bit.TEMPCONV = 1; //Connect channel A5 internally to the temperature sensor

AdcRegs.ADCSOC0CTL.bit.CHSEL = 5; //Set SOC0 channel select to ADCINA5
AdcRegs.ADCSOC0CTL.bit.ACQPS = 25; //Set SOC0 acquisition period to 26 ADCCLK
// delay sample de 577.78ns

AdcRegs.INTSEL1N2.bit.INT1SEL = 0; //Connect ADCINT1 to EOC0
AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enable ADCINT1

// Set the flash OTP wait-states to minimum. This is important
// for the performance of the temperature conversion function.
FlashRegs.FOTPWAIT.bit.OTPWAIT = 1;
int ii = 0;
//Main program loop - continually sample temperature
while (1) {

for (ii = 0; ii < 1024; ii++) {

//Force start of conversion on SOC0
AdcRegs.ADCSOCFRC1.all = 0x01;

//Wait for end of conversion.
while (AdcRegs.ADCINTFLG.bit.ADCINT1 == 0) {
} //Wait for ADCINT1
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1

//Get temp sensor sample result from SOC0
adc_sample[ii] = AdcResult.ADCRESULT0;
// DSP28x_usDelay(1000L);
}

for (ii = 0; ii < 1024; ii++)

adc_vol[ii]=adc_sample[ii]*3.3/4095;


asm("nop");


}
}