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 all,
I am new with the dsp's. I am trying to setup the adc of the Piccolo 28027. I want to convert the channels in simultaneous mode.
My first step has been trying to modify the example called lab3 but it doesn't work.
My code is the following:
void InitAdc(void)
{
asm("EALLOW"); //Enable EALLOW protected register access
AdcRegs.ADCCTL1.bit.RESET=1; //Reset the ADC module
//Must wait 2 ADCCLK periods for the reset to take effect.
//Note that ADCCLK=SYSCLKOUT for F2802x/F2803x devices.
//Power-up and configure the ADC
AdcRegs.ADCCTL1.all= 0x00E4;
DelayUs(1000); //Wait 1ms after power-up before using the ADC.
//**************************************************************************************
//SOCx configuration
//AdcRegs.ADCSAMPLEMODE.all=0x00FF;
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0=1; // the following instructions mean
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN2=1;// in simultaneous sample mode (vs. single sample mode)
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN4=1;
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN6=1;
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN8=1;
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN10=1;
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN12=1;
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN14=1;
//**************************************************************************************
// AdcRegs.ADCSOCxCTL.bit.TRIGSEL=7; //Trigger using ePWM2-ADCSOCA
AdcRegs.ADCSOC0CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC1CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC2CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC3CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC4CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC5CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC6CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC7CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC8CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC9CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC10CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC11CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC12CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC13CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC14CTL.bit.TRIGSEL=7;
AdcRegs.ADCSOC15CTL.bit.TRIGSEL=7;
//****************************************************************************************
// AdcRegs.ADCSOCxCTL.bit.CHSEL=0 //Ver tabla 17 para otras configuraciones.
// SOCx channel select. Selects the channel to be converted when SOCx is received by the ADC.
// The following instructions are for Simulatenous Sampling Mode/SIMULENx=1)
AdcRegs.ADCSOC0CTL.bit.CHSEL=0; // seleccion de canal
AdcRegs.ADCSOC2CTL.bit.CHSEL=1; // seleccion de canal
AdcRegs.ADCSOC4CTL.bit.CHSEL=2; // seleccion de canal
AdcRegs.ADCSOC6CTL.bit.CHSEL=3; // seleccion de canal
AdcRegs.ADCSOC8CTL.bit.CHSEL=4; // seleccion de canal
AdcRegs.ADCSOC10CTL.bit.CHSEL=5; // seleccion de canal
AdcRegs.ADCSOC12CTL.bit.CHSEL=6; // seleccion de canal
AdcRegs.ADCSOC14CTL.bit.CHSEL=7; // seleccion de canal
//*******************************************************************************************
//AdcRegs.ADCSOCxCTL.bit.ACQPS=6;// Sampling Windows is 7 cycles long(6+1 clock cycles).
//The quickest sampling window.
AdcRegs.ADCSOC0CTL.bit.ACQPS=6;
AdcRegs.ADCSOC1CTL.bit.ACQPS=6;
AdcRegs.ADCSOC2CTL.bit.ACQPS=6;
AdcRegs.ADCSOC3CTL.bit.ACQPS=6;
AdcRegs.ADCSOC4CTL.bit.ACQPS=6;
AdcRegs.ADCSOC5CTL.bit.ACQPS=6;
AdcRegs.ADCSOC6CTL.bit.ACQPS=6;
AdcRegs.ADCSOC7CTL.bit.ACQPS=6;
AdcRegs.ADCSOC8CTL.bit.ACQPS=6;
AdcRegs.ADCSOC9CTL.bit.ACQPS=6;
AdcRegs.ADCSOC10CTL.bit.ACQPS=6;
AdcRegs.ADCSOC11CTL.bit.ACQPS=6;
AdcRegs.ADCSOC12CTL.bit.ACQPS=6;
AdcRegs.ADCSOC13CTL.bit.ACQPS=6;
AdcRegs.ADCSOC14CTL.bit.ACQPS=6;
AdcRegs.ADCSOC15CTL.bit.ACQPS=6;
//**********************************************************************************************
//AdcRegs.ADCINTSOCSELy.bit.SOCx=0; //ADC Interrupt Trigger selection.
//In this case, 0 means that NO ADC INT will trigger SOCx.
AdcRegs.ADCINTSOCSEL1.all = 0x0000;
AdcRegs.ADCINTSOCSEL2.all = 0x0000;
//AdcRegs.ADCINTSOCSEL1.bit.SOC0=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC1=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC2=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC3=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC4=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC5=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC6=0;
//AdcRegs.ADCINTSOCSEL1.bit.SOC7=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC8=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC9=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC10=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC11=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC12=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC13=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC14=0;
//AdcRegs.ADCINTSOCSEL2.bit.SOC15=0;
//***************************************************************************************
//AdcRegs.SOCPRICTL.bit.SOCPRIORITY=0; // All SOC's handled in round-robin mode.
AdcRegs.SOCPRICTL.bit.SOCPRIORITY=1;
//***************************************************************************************
AdcRegs.INTSEL1N2.bit.INT1CONT=0; // ADCINT0 pulses generated only when ADCINT0 flag is clear
AdcRegs.INTSEL1N2.bit.INT1E=1; // Enable ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0; // EOC0 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=1; // EOC1 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=2; // EOC2 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=3; // EOC3 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=4; // EOC4 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=5; // EOC5 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=6; // EOC6 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=7; // EOC7 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=8; // EOC8 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=9; // EOC9 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0xA; // EOC10 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0xB; // EOC11 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0xC; // EOC12 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0xD; // EOC13 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0xE; // EOC14 triggers ADCINT0
AdcRegs.INTSEL1N2.bit.INT1SEL=0xF; // EOC15 triggers ADCINT0
PieCtrlRegs.PIEIER1.bit.INTx1=1; //Enable ADCINT0 in IER to enable PIE Group
IER|= 0x0001;
AdcRegs.ADCCTL1.bit.ADCENABLE=1;
asm("EDIS");
} //end InitAdc()
Can anybody tell what is wrong? Or correct?
Thank you
hmm what "does not work" exactly?? a little bit more information about your problem would be helpful...
best regards
Andreas
Hi Andreas:
Thank you for your interest. This was my first post, when I was lost trying to program the piccolo ADC.
Now, my code is working. What I have done is to modify the code of the example Lab3, but step by spep. I mean, I've set up every channel instead of setting them up as you've seen in the post. So now I take a channel and I configure it, then... I configure the following one and so on.
I really don't know if that was my problem but the fact is that now it's working properly.
By all the way, thank you very much.
Best regards.
Did your code right what u posted? i did the same programming but giving problem.
Can you suggest me what to do
Thank you
Hi:
Sorry for replying so late but....I was spending my holidays. You Know: no laptop, no phone...no thinking.
As I said the first time I posted, the code that you can see at the top didn't work.
After that, I programmed every channel in a secuential way, I mean, I set up a channel... then other. It worked fine.
If you want I can send you my code.
Best regards.
thats ok but i m very happy to read your reply. I want that ADC part as i am stucked with it i have completed PWM program it is working well but not ADC.
If u have No problem then can you send me please
thank you
cheers
Dear JOze
my name is Sutanto , and can i please have your Code from this Piccolo ADC ? (modify from Lab3)
my E-mail: sutantorahmat@gmail.com
Many Many Thanks for Your Help
Regards
Rahmat Sutanto