Hallo!
Ich versuche gerade den ADC der oben genannten DSP zum laufen zu
bekommen.
Der ADC sollte dreimal hintereinander den Kanal B0 wandeln. Mit Hilfe
der 3 Werte wird eine Mittelwertbildung, zur Bestimmung eines Offsets
durchgeführt.
Leider funktioniert das nicht, und ich weis nicht warum... :(. Es werden
permanent unterschiedliche Werte gemessen. Von 0 bis (Uint16) 2230,
obwohl der Pin auf Ground liegt.
Hoffe jemand kann mir da helfen. Der Code:
1 | AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; // Sequential mode: Sample rate = 1/[(2+ACQ_PS)*ADC clock in ns]
|
2 | // = 1/(3*40ns) =8.3MHz (for 150 MHz SYSCLKOUT)
|
3 | // = 1/(3*80ns) =4.17MHz (for 100 MHz SYSCLKOUT)
|
4 | // If Simultaneous mode enabled: Sample rate = 1/[(3+ACQ_PS)*ADC clock in ns]
|
5 | AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x0;
|
6 | AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 1 Cascaded mode
|
7 | AdcRegs.ADCCHSELSEQ1.bit.CONV00=0x8; // ADCIB0
|
8 | AdcRegs.ADCCHSELSEQ1.bit.CONV01=0x8; // ADCIB0
|
9 | AdcRegs.ADCCHSELSEQ1.bit.CONV02=0x8; // ADCIB0
|
10 | AdcRegs.ADCTRL1.bit.CONT_RUN = 1; // Setup continuous run
|
11 |
|
12 | AdcRegs.ADCTRL1.bit.SEQ_OVRD = 0; // Enable Sequencer override feature
|
13 |
|
14 | AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 0x2;
|
15 |
|
16 |
|
17 | AdcRegs.ADCRESULT0=0x0;
|
18 | AdcRegs.ADCRESULT1=0x0;
|
19 | AdcRegs.ADCRESULT2=0x0;
|
20 |
|
21 | AdcRegs.ADCTRL2.bit.SOC_SEQ1=0x1;
|
22 |
|
23 |
|
24 | while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
|
25 | Ioffset=(( (AdcRegs.ADCRESULT0)>>4)+( (AdcRegs.ADCRESULT1)>>4)+( (AdcRegs.ADCRESULT2)>>4))/3;
|
26 |
|
27 | AdcRegs.ADCTRL2.bit.SOC_SEQ1=0x0;
|
28 | AdcRegs.ADCTRL2.bit.RST_SEQ1=0x1;
|
Viele Grüße
Max