ADC forwarding directly to UART

adcmicrocontrollertexas instrumentsuart

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?

Best Answer

You will want to sample at a regular interval with as little jitter as possible so setup your MCU program to operate with a timer interrupt at your needed sample rate. Then at each interrupt read the results of the previous conversion and trigger the next conversion. Some MCUs have built in hardware than can be configured to trigger A/D conversions from a timer overflow.

From the questions you have asked above it seems that you will need to do some investigation into your particular MCU to figure out how to use the timers and interrupts.

UARTs are good for 8-bit data bytes. The way you transmit 12-bits from an A/D converter is one of several ways.

a) Send first 8-bits of the sample in one UART byte followed by 4-bits in the next UART byte.

b) Send the first 6-bits in a UART byte followed by the remaining 6-bits in the next UART byte.

c) Both above approaches waste UART bandwidth on bit times not transmitting useful data so another scheme is to send two samples of the A/D (2 x 12 bits) packed into three UART bytes (3 x 8 bits). The packing can be sliced many ways but one common method used is to send the following sequence [Sample1(7:0)] [Sample2(7:0)] [Sample1(11:8)Sample2(11:8)].