ADC Sequencer in TMS28xx

Hallo, in einem F2808 µC Controller möchte ich den Sequencer dazu nutzen Alle 16 Kanäle auszulesen. Das probier ich schon ne ganze weile ohne es zum klappen zu bringen.

Gibt es von TI Beispielcode dafür , den ich übersehen habe? Gibt es spezielle Fallen, die es zu umschiffen gilt?

spru716b kenn ich schon, und meine es verstanden zu haben. Ja ich weiß, irgendwo darin liegt die Lösung, nur ich finde sie nicht.

Code Snippet :

Die Statemachine wird zyklisch abgefragt.

void AdcStateMachine(void) {

switch ( AdcState ) {

case START : AdcRegs.ADCTRL2.all = 0x2000; // // Reset SEQ1 // Reset SEQ2 AdcState = RUN ; break ;

case RUN : // if (AdcRegs.ADCASEQSR.bit.SEQ_CNTR== 0) if ( AdcRegs.ADCST.bit.INT_SEQ1== 1) { Adc0 = AdcRegs.ADCRESULT0 ; Adc1 = AdcRegs.ADCRESULT1 ; Adc2 = AdcRegs.ADCRESULT2 ; Adc3 = AdcRegs.ADCRESULT3 ; Adc4 = AdcRegs.ADCRESULT4 ; Adc5 = AdcRegs.ADCRESULT5 ; Adc6 = AdcRegs.ADCRESULT6 ; Adc7 = AdcRegs.ADCRESULT7 ; Adc8 = AdcRegs.ADCRESULT8 ; Adc9 = AdcRegs.ADCRESULT9 ; Adc10 = AdcRegs.ADCRESULT10 ; Adc11 = AdcRegs.ADCRESULT11 ; Adc12 = AdcRegs.ADCRESULT12 ; Adc13 = AdcRegs.ADCRESULT13 ; Adc14 = AdcRegs.ADCRESULT14 ; Adc15 = AdcRegs.ADCRESULT15 ;

AdcRegs.ADCST.bit.INT_SEQ1= 0 ; AdcState = START ; } break ;

default : AdcState = START ; break ;

}

}

extern void DSP28x_usDelay(Uint32 Count);

// To powerup the ADC the ADCENCLK bit should be set first to enable // clocks, followed by powering up the bandgap, reference circuitry, and ADC core. // Before the first conversion is performed a 5ms delay must be observed // after power up to give all analog circuits time to power up and settle

// Please note that for the delay function below to operate correctly the // CPU_CLOCK_SPEED define statement in the DSP280x_Examples.h file must // contain the correct CPU clock period in nanoseconds.

AdcRegs.ADCTRL1.all = 0x4000 ; // // Reset

DELAY_US(ADC_usDELAY);

AdcRegs.ADCTRL1.all = 0x0008 ; // // Reset // SEQ16 Mode

AdcRegs.ADCTRL2.all = 0x4040; // // Reset SEQ1 // Reset SEQ2

DELAY_US(ADC_usDELAY);

AdcRegs.ADCTRL3.all = 0x00E0; // // Power up bandgap/reference/ADC circuits

DELAY_US(ADC_usDELAY);

AdcRegs.ADCMAXCONV.all = 0x000f ; // 16 Sequence DELAY_US(ADC_usDELAY);

AdcRegs.ADCREFSEL.all = 0x0000 ; // internal reference

DELAY_US(ADC_usDELAY);

AdcRegs.ADCCHSELSEQ1.all = 0x3210 ; AdcRegs.ADCCHSELSEQ2.all = 0x7654 ; AdcRegs.ADCCHSELSEQ3.all = 0xba98 ; AdcRegs.ADCCHSELSEQ4.all = 0xfedc ;

DELAY_US(ADC_usDELAY);

AdcRegs.ADCTRL1.all = 0x0010 ;

DELAY_US(ADC_usDELAY); // Delay before converting ADC channels

Reply to
Andreas Ruetten
Loading thread data ...

Andreas Ruetten schrieb:

Hallo Andreas,

du möchtest also mit den beiden ADC Sequenzern kaskadiert und nacheinander (nicht-simultan) sampeln.

AdcRegs.ADCTRL3.bit.SMODE_SEL = 0x0; // Setup non-simultaneous sampling mode AdcRegs.ADCTRL1.bit.SEQ_CASC = 0x1; // Setup cascaded sequencer mode AdcRegs.ADCMAXCONV.all = 0x0007; // 8 double conv's (16 total) und dann 16 mal die Angabe auf welchem Kanal jeweils gesampelt werden soll.

ähnlich wie Beispiel 1-2 "Simultaneous Sampling Cascaded Sequencer Mode Example" in spru716b Seite 21. - Jedoch nicht simultan.

Es gibt sprc191 "C280x/C2801x C/C++ Header Files and Peripheral Examples".

Nach der Installation finden sich im folgenden Ordner drei Beispiele zum AD-Wandler. C:\tidcs\c28\DSP280x\v141\DSP280x_examples

AdcSeq_ovdTest und AdcSeq_xx - Diese sind ähnlich deinem skizzierten Code . (Polling)

AdcSoc - Dieses Beispiel ist mit ADC Interrupt, die Wandlung wird hier aber über das ePWM Modul ausgelöst. Das lässt sich auf Wunsch auch ohne machen durch das manuelle Setzen des Start of Conversion Bits (AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;).

Diese Beispiele arbeiten IMHO alle jeweils nur auf einem Kanal. Aber damit sollte sich arbeiten lassen.

Ich hoffe damit kommst du weiter.

Gruß Tobyas

Reply to
Tobyas Hennig

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.