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.

Using ADC and UART on TM4C123GH6PM

I have an TM4C123GH6PM, I have also the board EK-TM4C123GXL with that MCU. I am new to microprocessors and still studying to learn. I have to implement a project with a Bluetooth module, which connects over UART to a host MCU. I want to know if I can use this MCU for the host.

The MCU will read an analog signal, and must sample continuously and periodically with a rate of at least 8000-10000 samples per second. In real time, this data will be forwarded directly to the UART and sent to the Bluetooth module. My questions are,

  • First of all, is this possible with this MCU?
  • Secondly, I know how to use UART and how to use ADC basically, but how do I configure ADC to run periodically and continuously - if that is not the default- ?
  • Thirdly, as I know, the UART operates with 10 bits when there is only one stop bit and no parity bit, the remaining is 8 bits, how do I workaround to get 12 bits of data per sample from ADC, other than truncating?

Thanks in advance. 

  • Hello Jacob,

    1. ADC will sample at the lowest rate of 125ksps. If you want it to do anything less then perhaps use the averaging.

    2. There are a few posts in the last week on ADC. Might a suggest a search in the E2E forum

    3. Other than truncating the LSB's I am not sure how the other end (i.e. Bluetooh)  is expecting the data. A little more insight on the format the BT device expects the data would be good.

    Regards

    Amit

  • The limitations are no problem?

    1. Ok, or can I have interrupts for that, triggered by timer? How can I do that?

    3. No problem about the Bluetooth side, it is raw data, transmitted to be a computer. 

  • Hello Jacob

    1. Yes, you can trigger a ADC from a timer and then use the interrupt from the ADC to read the data. There is a simple ADC conversion using CPU trigger available in the TIVWare examples. You can use that as a starter code.

    Regards

    Amit

  • Jacob Lively said:
    UART data is 8 bits, how do I workaround to get 12 bits of data per sample from ADC, other than truncating?

    Appears this issue has been, "passed."

    Several classic methods have past been employed:

    a) Reserve 2 UART byte transmissions for one, 12 bit ADC reading.  You are free to mix/match - often according to "coding ease" - some find, "ORing the most significant 4 ADC bits into UART byte one - followed by the remaining 8 ADC bits into UART byte two - works well.

    b) Perhaps more efficient - you copy the ADC's 8 lsb into UART byte one - then perform 4 right shifts - and pass UART byte two.  (the RX side strips out the 4 irrelevant ls bits.

    c) To minimize UART activity - some encode two ADC readings w/in three UART transfers.  Usually - but not always - the 3rd UART byte contains the top 4 bits of each ADC reading.  The receive side "knows what's what" and redorders as needed...

    Do keep in mind that 12 bits from any mixed signal device is largely "ceremonial" - not to bet the farm upon the accuracy or repeatability of the 3 (or even 4) ls bits...  (thus you may get by with a single UART xmsn - carrying the 8 msb from the ADC.  (i.e. the ADC's "real" value bits...)  Note: all MCU ADCs suffer this - not a knock on this maker - simple reality intruding, again...