Link to this post 06 Feb 14


Iam using Pantech F2812 kit. I would like to feed just an analog unipolar input 0-3V using function generator to ADC, so that i could observe the corresponding digital value in register. But i would like to know how is ADC pin configured in your kit.Expecting a reply at the earliest'

Kind Regards

Link to this post 06 Feb 14

Could you please help me in this doubt i posted

Link to this post 06 Feb 14


Our TMS320F2812 processor can able to do the ADC operation for your unipolar analog input 0-3v. Only few registers are required to configure and run the ADC. here i provided simple ADC configuration example to convert Analog voltage at ADCINA0,ADCINA1,ADCINA2,ADCINA3 these configuration you may vary according to your project.

Example configuration:

EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.ADCINT = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers

// Enable ADC interrupt: PIE-Group1 , interrupt 6
PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

// Enable CPU INT1 which is connected to ADC interrupt:
IER = 1;

// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

// Configure ADC
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 0 - Dual & 1 - Cascade Sequencer Mode
AdcRegs.ADCTRL1.bit.CONT_RUN = 0; // 0 - No Continuous run & 1 - Continuous run
AdcRegs.ADCTRL1.bit.CPS = 1; // prescaler = 1
AdcRegs.ADCMAXCONV.all = 0x0003; // Setup 4 conv's on SEQ
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; // Setup ADCINA0 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1; // Setup ADCINA1 as 2nd SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2; // Setup ADCINA2
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3; // Setup ADCINA3
AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1 = 1; // Enable EVASOC to start SEQ1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every
EOEvaRegs.GPTCONA.bit.T1PIN = 1;
AdcRegs.ADCTRL3.bit.ADCCLKPS = 2; // Divide HSPCLK by 4

// Configure EVA
// Assumes EVA Clock is already enabled in InitSysCtrl();
// Disable T1PWM / T2PWM outputs
EvaRegs.GPTCONA.bit.TCMPOE = 0;
// Polarity of GP Timer 1 Compare = forced low
EvaRegs.GPTCONA.bit.T1PIN = 0;
EvaRegs.GPTCONA.bit.T1TOADC = 2; // Enable EVASOC in EVA

EvaRegs.T1CON.bit.FREE = 0; // Stop on emulation suspend
EvaRegs.T1CON.bit.SOFT = 0; // Stop on emulation suspend
EvaRegs.T1CON.bit.TMODE = 2; // Continuous up count mode
EvaRegs.T1CON.bit.TPS = 1; // prescaler = 1
EvaRegs.T1CON.bit.TENABLE = 1; // enable GP Timer 1
EvaRegs.T1CON.bit.TCLKS10 = 0; // internal clock
EvaRegs.T1CON.bit.TCLD10 = 0; // Compare Reload when zero
EvaRegs.T1CON.bit.TECMPR = 0; // Disable Compare operation

we are using ADC and Event Manager registers. here Event manager is used for ADC Start of Conversion(SOC).

Kindly Place this below codings at ADC_ISR ADC Interrupt Service Routine to update the new ADC value.
Note: Declare this global variable Voltage_A0,Voltage_A1,Voltage_A2,Voltage_A3 as unsigned int or int. for every interrupt it updates the four ADC conversion values.

Voltage_A0 = AdcRegs.ADCRESULT0>>4;
Voltage_A1 = AdcRegs.ADCRESULT1>>4;
Voltage_A2 = AdcRegs.ADCRESULT2>>4;
Voltage_A3 = AdcRegs.ADCRESULT3>>4;

// Reinitialize for next ADC sequence
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE

For each line i explained comments for appropriate lines.

Important Notes:
Before feed an analog voltage to kit, kindly check the voltage. it must be < 3.3v otherwise processor ADC pin may damage.

Link to this post 06 Feb 14

Hi Sir
Thankyou for posting this. But i have written the code already and my doubt is regarding the pin in F2812 kit, Where to connect the analog input to ADC in kit? Is there any schematic for pin configuration for ADC?

Link to this post 06 Feb 14


According to the previous program , you have to give input to the ADCINA0, ADCINA1, ADCINA2, ADCINA3 . But in our TMS320F2812 TYRO kit we have already connected Trimpot(Variable Resistor) for these pin.

At first step , you just vary the trimpot to check whether your adc code is worked .

if you succeeded at the first step then remove those trimpot to give your real input from function generator or regulated power supply.

Note: you can give input through J7 connector(at bottom , left corner of the kit)

  1. png