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.

2810 ADC问题



我的 ADC配置和读取函数如下,可数据没有,请帮忙看看问题在哪里,谢谢。

void F281X_ileg2_dcbus_drv_init(ILEG2DCBUSMEAS *p)
{

AdcRegs.ADCTRL3.bit.ADCBGRFDN = 0x3; // Power up bandgap/reference circuitry

MYDELAY_US(10L);
AdcRegs.ADCTRL3.bit.ADCPWDN = 1; // Power up rest of ADC
MYDELAY_US(1000L);
AdcRegs.ADCTRL3.bit.SMODE_SEL=1; //同时 sampling mode
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; //级联
AdcRegs.ADCMAXCONV.all = 0x07; // 8个通道

AdcRegs.ADCCHSELSEQ1.bit.CONV00=0x0;//ADCINA0,ADCINB0 A0,B0
AdcRegs.ADCCHSELSEQ1.bit.CONV01=0x1;//ADCINA0,ADCINB0 A1,B1
AdcRegs.ADCCHSELSEQ1.bit.CONV02=0x2;//ADCINA0,ADCINB0 A2,B2
AdcRegs.ADCCHSELSEQ1.bit.CONV03=0x3;//ADCINA0,ADCINB0 A3,B3
AdcRegs.ADCCHSELSEQ2.bit.CONV04=0x4;//ADCINA2,ADCINB2 A4,B4
AdcRegs.ADCCHSELSEQ2.bit.CONV05=0x5;//ADCINA2,ADCINB2 A5,B5
AdcRegs.ADCCHSELSEQ2.bit.CONV06=0x6;//ADCINA2,ADCINB2 A6,B6
AdcRegs.ADCCHSELSEQ2.bit.CONV07=0x7;//ADCINA7,ADCINB7 A7,B7

EvaRegs.GPTCONA.bit.T1TOADC = 1; // Enable EVASOC in EVA


AdcRegs.ADCTRL1.bit.ACQ_PS=10; //5->10
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL3.bit.ADCCLKPS=10;


}

void F281X_ileg2_dcbus_drv_read(ILEG2DCBUSMEAS *p)
{

int16 DatQ15;
int32 Tmp;
// Wait until ADC conversion is completed

while (AdcRegs.ADCST.bit.SEQ1_BSY == 1)
{};

DatQ15 =AdcRegs.ADCRESULT0^0x8000; // Convert raw result to Q15 (bipolar signal)
Tmp =(int32)p->ImeasAGain*(int32)DatQ15; // Tmp = gain*dat => Q28 = Q13*Q15
p->ImeasA =(int16)(Tmp>>18); // Convert Q28 to Q15
p->ImeasA += p->ImeasAOffset; // Add offset
p->ImeasA *= -1; // Positive direction, current flows to motor

DatQ15 =AdcRegs.ADCRESULT1^0x8000; // Convert raw result to Q15 (bipolar signal)
Tmp =(int32)p->ImeasBGain*(int32)DatQ15; // Tmp = gain*dat => Q28 = Q13*Q15
p->ImeasB =(int16)(Tmp>>18); // Convert Q28 to Q15
p->ImeasB += p->ImeasBOffset; // Add offset
p->ImeasB *= -1; // Positive direction, current flows to motor

DatQ15 = (AdcRegs.ADCRESULT15>>1)&0x7FFF; // Convert raw result to Q15 (unipolar signal)

Tmp = (int32)p->VdcMeasGain*(int32)DatQ15; // Tmp = gain*dat => Q28 = Q13*Q15
if (Tmp > 0x0FFFFFFF) // Limit Tmp to 1.0 in Q28
Tmp = 0x0FFFFFFF;
p->VdcMeas = (int16)(Tmp>>13); // Convert Q28 to Q15 //zhoujt 6.12 13

p->VdcMeas += p->VdcMeasOffset; // Add offset

p->ImeasC = -(p->ImeasA + p->ImeasB); // Compute phase-c current

AdcRegs.ADCTRL2.all |= 0x4040; // Reset the sequence

}