TI E2E Community
Stellaris® ARM® Microcontrollers
Stellaris® ARM® LM3S Microcontrollers Forum
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?
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.
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,
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.