This laboratory assignment will familiarize you with the one of the serial communications peripherals of the ARM Cortex M0. The UART, or Universal Asynchronous Receiver/Transmitter, is a hardware peripheral that makes sending and receiving bytes of data between embedded components extremely fast and easy. All of the overhead control, like start and stop bits, parity, and baudrate, are easily configurable through the hardware control registers as with other peripherals that you have previously worked with, and NXP provides a nice example project to help get us started. Lastly, this lab is also important from the perspective of completing your final project, as in order to do so you will need to be able to stream collected data across Bluetooth from the embedded device you will build for real-time data processing in your Android phone.
Figure 1. The communication flow achieved during this laboratory.
The Bluetooth module is the device
that you will leverage for both this lab as well as your final
project (so treat it well!). This Bluetooth device is a
module, meaning that it is in actuality composed of more than
one IC chip (a BlueCore chip with a separate microcontroller
to operate it), although it is treated as one chip with one
footprint. This particular version comes with its own on
board voltage regulator and convenient access to the UART
Tx/Rx communication pins.
1: Solder wires connecting the Vcc, GND, Tx,
and Rx pins from the LPCXpresso board to the BlueSMiRF
device--make sure that the Arm UART's Rx connects to the
BlueSMiRF Tx (not Tx to Tx or Rx to Rx!).
Note: When connecting the
BlueSMiRF device to your phone for the first time, you need to
"pair" the device with your phone. This is only required
for the first time, and can be done with the default password
You are going to leverage an
Android phone/tablet to receive the serial communications from
the embedded hardware.
For this project, you will utilize
another NXP example project--"uart". Please locate,
open, and compile this project. By coincidence, the
BlueModule's default firmware is set to the same serial
communications configuration (9600 baud, 8 bits, no Parity, 1
stop bit), however be aware that with other Bluetooth radios
you may need to configure this portion yourself. (Note: Verify
the Bluetooth module does in fact have its baudrate set at
9600 by looking into the documentation.)
3: Initiate a debugging session with the "uart"
project, and connect your Android phone to your specific
Bluetooth device (i.e., make sure not to connect to another
group's device). Test the example's functionality by
sending some characters from your Android phone and seeing if
they are echoed back by the Arm Cortex M0.
4: Modify the code in the "uart" example
project such that you repeat a message of "Hello World!\n" at
some fixed delay interval of your choosing.
Now that you understand the
fundamentals of using the Arm Cortex M0 to facilitate
communication between Bluetooth module and the Serial Bluetooth
Program, let's do something more useful. For the second
portion of the lab assignment, you are going to use your
phone/tablet to control the Arm Cortex M0 peripherals, and
namely, the GPIO and ADC ports (GPIO is required, ADC is
optional and 10% extra credit). To do this, you will have
the Arm display a menu system to the Bluetooth terminal
application, with which you can interact to set different
parameters for the two peripherals.
Table 2 describes the
expected overall flow of the menu system.
You have already provided solutions for
the control of the LED's blinking frequency and duty cycle in
previous lab assignments, but the parametrization was set
statically at compile time, and not dynamically
accessible. In this assignment, you remedy such
inflexibility and provide a method of remote configuration for
your embedded system – your Android phone.
The end goal of this
assignment is an ability to traverse these menus at will from
your phone's Bluetooth terminal, and enact the desired changes
in the peripheral's operation as indicated by the menu
choices. Only the first character of any string of
characters sent from the Android phone should be considered, and
the rest thrown away. Each new menu with all options
should be displayed in full upon reaching it. You may
select the meaning of 'Slow', 'Fast', etc, for both LED and ADC
find that the menu is rapidly displaced by the reported ADC
values. This is perfectly okay, as you can refer to this
page for which number selections correspond to which menu
options. You will also need to devise a way to send the
voltage values. Remember, the ADC peripheral reports its
voltage by a counting of the number of (3.3-0)/2^10 divisions
that a measured voltage is closest to. Keep in mind that
even if you chose to just send this count number, that the
Bluetooth terminal will interpret it as an ASCII value and print
the corresponding characters to your Android screen. There
is no set or right way to handle this, but try to see if you can
come up with some interesting solutions to this problem.
|Arm Peripheral Control Menu
1. Control LED
2. Control ADC
LED Control Menu
LED Frequency Menu
LED Duty Cycle Menu
Reporting Frequency Menu
Figure 2. The Arm peripheral configuration menu flow (blue parts are required, .