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.
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");
}
}
Martin,
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //Set SOC0 channel select to ADCINA0
AdcRegs.ADCSOC1CTL.bit.CHSEL = 1; //Set SOC1 channel select to ADCINA1
AdcRegs.ADCSOC2CTL.bit.CHSEL = 2; //Set SOC2 channel select to ADCINA2
AdcRegs.ADCSOC3CTL.bit.CHSEL = 3; //Set SOC3 channel select to ADCINA3
AdcRegs.ADCSOC4CTL.bit.CHSEL = 9; //Set SOC4 channel select to ADCINB1
regards
Gastón
there is a guide where you can find more information on the registration "ADCSOCXCTL" I searched the manual but no specifications on it!
greetings and thanks for the help.
Hi Gautam, actually I was quite surprised with the C2000 is an excellent processor, I like its 3.4MSPS sampling rate, although today in the morning I ran into a problem with the RAM trying to declare a vector
Uint16 Adc_sample[1024];
maybe I made a mistake somewhere, but if I turn to run into the problem, I'll start another forum on this topic.
Thanks for welcoming me.
greetings
Martin Valencia
F28069 + RAM sectors - C2000 microcontrollers forum - C2000™︎ microcontrollers - TI E2E support foru...
Here is a link about my problem with RAM TMS320F28069
hehehe :-)
I seem to have to do something about the position of the RAM