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.

TM4C123GH6PM: ADC

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Page 803:

For example, if Sequencer 0 is used, the END bit can be set in the nibble associated with the fifth sample, allowing Sequencer 0 to complete
execution of the sample sequence after the fifth sample.

Page 856

5th Sample is End of Sequence

Value   Description
0         Another sample in the sequence is the final sample.


1         The fifth sample is the last sample of the sequence.
It is possible to end the sequence on any sample position. Software
must set an ENDn bit somewhere within the sequence. Samples defined
after the sample containing a set ENDn bit are not requested for
conversion even though the fields may be non-zero.

My question is if END bit of the 5th sample is set, that will be the last sample, how it will be executed to the 8th sample?

  • In that case it will not make an eighth conversion for that sequence, it will only make 5. If 8 different samples are desired for that sequence, then the END bit should only be set for the the eighth step. But don't confuse the number of samples with the FIFO depth. Sequence 0 also has a FIFO depth of 8. If you configure the sequence for 5 samples, and get another trigger (restart the sequence) before you read any of the values from the FIFO, it will continue to fill until the FIFO is full with eight values.

  • Greetings,

    Most excellent, "Add-On" detailing ADC's FIFO management - thank you - much appreciated.

    There lurks the 'sub-case' - in which (some) but not all - of the FIFO values have been read & (then) another trigger arrives.   Might that alter the "FIFO's operation" from that described - as your post notes?    We ask as, "Should that be possible" - then a "Test for FIFO's current 'fill-level' (assuming such is possible) may be indicated..."

    In addition - should the FIFO's content not be fully "read/extracted" - and another trigger arrives (possibly prematurely) - are those earlier FIFO results in danger of being over-written?

    Thank you Bob for this key guidance and your time/attention...

  • Hi Bob,

     Assuming SS0, and END2 is set; with the first trigger I would received 3 samples and the HTPR pointer would be increased to 0x03.

    1) If I didn't read them would the second trigger be written on 0x03-0x5 and HTPR would be advanced to 0x6. Would overflow flag be set?

    2)Would the 3rd trigger be written on 0x6, 0x7,0x0 and advanced HTPR to 0x1? and is this the only condition that set the overflow flag?

  • Are you asking these details out of curiosity, or are you trying to figure out how to setup the ADC converter? If it is the latter, you should use the TivaWare driver library provided by TI. This simplifies the register details. There is an advanced example in C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\adc_udma_pingpong that shows configuring the timer to periodically start the ADC and the DMA to read the results and store them in RAM. The steps of the sequence are configured with calls to the function ADCSequenceStepConfigure(). To configure sequence 0 to convert AIN0, AIN1 and AIN2 would look like this:

        ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0 );
        ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1 );
        ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2 | ADC_CTL_END | ADC_CTL_IE);
    

    Note that the attribute ADC_CTL_END is only set for the last step. Also I chose to enable an interrupt request after the channel 2 conversion completes.

    When not using DMA, reading from the FIFO is done with the function ADCSequenceDataGet(). This function, and other TivaWare functions, are described in: C:\ti\TivaWare_C_Series-2.2.0.295\docs\SW-TM4C-DRL-UG-2.2.0.295.pdf. It reads all of the values in the FIFO storing them in a buffer you provide. It returns the number of entries read. You don't need to keep track of FIFO pointers. A call to the function ADCSequenceOverflow() will tell you if there was a FIFO overflow.

  • Bob Crosby said:

    Are you asking these details out of curiosity, 

    You got it. I know how to write the code as well as it is functioning; but that two questions I posted in the last post, I have  an answer but I want to be sure.

    Would you please clear that?

    Thanks Bob.

  • sonMEE said:
    Assuming SS0, and END2 is set; with the first trigger I would received 3 samples and the HTPR pointer would be increased to 0x03.

    sonMEE said:
    1) If I didn't read them would the second trigger be written on 0x03-0x5 and HTPR would be advanced to 0x6. Would overflow flag be set?

    No.

    sonMEE said:
    2)Would the 3rd trigger be written on 0x6, 0x7,0x0 and advanced HTPR to 0x1? and is this the only condition that set the overflow flag?

    Samples would be written in 0x6 and 0x7. Overflow flag would be set and HTPR would be at 0. You would loose the last sample, not the first sample.