0
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\begingroup\$ Should be fast enough - but it really depends on your Bluetooth module, the common HC-05 can be programmed to go up to 1382400 baud (which is greater than 100Kbytes/s) \$\endgroup\$
    – Zuofu
    Commented May 12, 2014 at 14:12

1 Answer 1

2
\$\begingroup\$

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)].

\$\endgroup\$
14
  • \$\begingroup\$ One advantage of method "b" above, is that each byte has two un-used bits, one of which could be used as an identifier to indicate which byte comes first. Without this, you would probably have to rely on timing to determine which comes first, and this timing could be difficult when passing data through Bluetooth or if passing to a device where communications timing is not so deterministic such as a PC. \$\endgroup\$
    – Tut
    Commented May 12, 2014 at 14:27
  • \$\begingroup\$ @Tut - Indeed framing is very important in any scheme like this. The 6/6 bit splits do permit framing marking to be added to the stream. I wonder if the OP is ready for that yet? \$\endgroup\$ Commented May 12, 2014 at 14:32
  • \$\begingroup\$ So, doing that for approximately 8000 - 10000 times/sec, for 16000 - 20000 UART packages/sec, is fine for this 80 MHz MCU? \$\endgroup\$
    – natsirun
    Commented May 12, 2014 at 14:48
  • \$\begingroup\$ @natsirun - You will have to evaluate your system requirements to determine the answer to your secondary question here. You'll need to see if the MCU and BlueTooth module can take baud rates at 10x the number of UART bytes per second. Another very important consideration is if the BlueTooth module has the capability and horsepower to receive the bytes at the high rate and still be able to utilize them for the BlueTooth channel. This is called "system design" and requires way more work than a question in EE StkXchg of "will it work". \$\endgroup\$ Commented May 12, 2014 at 14:57
  • \$\begingroup\$ I have Bluegiga WT12, the datasheet says it has a 3.0Mbaud rate at max, so I don't think I have problems in that. I am asking, if I can run this MCU that fast? \$\endgroup\$
    – natsirun
    Commented May 12, 2014 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.