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.

adc

 Hi, i'm working on f28335. I want to read adc on kit f28335. I'm read datasheet adc and configure resgister of adc. I supply 1voltage in pin ADCINA1 and read the value in Expresion but the result is not correct. Please help me with this problem. Thank you so much.

Here is the code in main.c and Init_adc

#include "DSP28x_Project.h"
#include "math.h"
extern void InitSysCtrl(void);
extern void InitAdc(void);
extern void InitPieCtrl(void);
extern void InitPieVectTable(void);
interrupt void adc_isr(void);
Uint16 LoopCount;
float Voltage1;
float Voltage2;
main()
{
LoopCount = 0;
InitSysCtrl();
EALLOW;
#if (CPU_FRQ_150MHZ)
#define ADC_MODCLK 0x3
#endif
EDIS;
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK;
EDIS;
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.ADCINT = &adc_isr;
EDIS;
InitAdc();
PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
IER |= M_INT1;
EINT;
ERTM;
// Assumes ePWM1 clock is already enabled in InitSysCtrl();
EPwm1Regs.ETSEL.bit.SOCAEN = 1;
EPwm1Regs.ETSEL.bit.SOCASEL = 4;
EPwm1Regs.ETPS.bit.SOCAPRD = 1;
EPwm1Regs.CMPA.half.CMPA = 0x0080;
EPwm1Regs.TBPRD = 0xFFFF;
EPwm1Regs.TBCTL.bit.CTRMODE = 0;
}
interrupt void adc_isr(void)
{
Voltage1 = AdcMirror.ADCRESULT0;
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
return;
}

init_adc:

#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
//
// Defines
//
#define ADC_usDELAY 5000L

void
InitAdc(void)
{
extern void DSP28x_usDelay(Uint32 Count);
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
ADC_cal();
EDIS;
AdcRegs.ADCTRL1.bit.RESET = 1;
asm(" RPT #10 || NOP");
AdcRegs.ADCREFSEL.bit.REF_SEL = 0;
AdcRegs.ADCTRL3.all = 0x00E8; // Power up bandgap/reference/ADC circuits
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
AdcRegs.ADCMAXCONV.all = 0x0000;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0000;

AdcRegs.ADCTRL1.all = 0x0710;
AdcRegs.ADCTRL2.all = 0x0900; //SEQ1 to be started by SOCA from ePWM module

AdcRegs.ADCOFFTRIM.bit.OFFSET_TRIM = 0; // Set Offset Error Correction Value
AdcRegs.ADCREFSEL.bit.REF_SEL =0;

AdcRegs.ADCRESULT0;
AdcMirror.ADCRESULT0;

PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
IER |= 0x0001;
}