Hello,
I am using the developement kit eki-lm3s8962
I am trying to configure the ADC to read a single sample but it's not working.
I need to read the ADC value in the same time of the encoder so i'm using a timer interrupt handler, and in every interrupt i read the value of ADC and encoder.
I configure the ADC like this:
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC);ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_ALWAYS, 0);ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_CH0 | ADC_CTL_END);ADCSequenceEnable(ADC_BASE, 0);
In the interrupt handler i read the value of ADC directly from ADC_SSFIFO0_R (the "ADCSequenceDataGet(ADC_BASE, 0, &ulValue);" doesn't work)
The program apparently works fine but i'm reading the ADC value from 8 past samples, for example
Real sample = [ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0]
i'm reading = [X X X X X X X X 1 2 3 4 5 6 7 8 9 0 1 2 3]
Someone can help me?
Best regards,
Felipe
Hi Felipe,
If I understand your configuration correctly, then the result you're seeing is expected (except for the bit about ADCSequenceDataGet(..) not working).
Sample Sequencer 0 has an 8 deep FIFO. If the ADC is free-running, then when your timer interrupt occurs (assuming it's interval is > 8 X the ADC interval), then you'll need to read 8 results from the FIFO to get to the most-recent conversion result. Presumably the most recent ADC result is the one you want since it aligns to the Timer event.
Try switching to Sample sequencer 3 which has a 1 deep FIFO.
Jonathan Guy
Hi Jonathan,
You understood what was happening,
About use the SS 3, was my first test but in the future i will need to use another SS.
I think i unterstand the FIFO now, and doing some tests i think i solve the problem
I am reading the ADC_SSFIFO0_R 8 times and only storing de last one.
I will make some tests but i think it's working now.
Thank you for your attention,