Microcontroller commands are
typically written in the Assembly programming language. In the Embedded Control
course, we will be writing code in the C programming language and compiling it
into Assembly. The SiLabs IDE software will check for
syntax errors, compile the code, and download it into the microcontroller flash
memory. The microprocessor will execute the programs stored in its memory, and
does not need to be connected to any other computer to function. Many programs
we will write in this course, though, will have user interaction in the form of
text printed on a screen and keyboard inputs, although feedback can be provided
by other means such as turning on/off LEDs or buzzers
or making adjustments to the motors connected to the microcontroller. In order
to view the text, though, we will need an additional communication connection –
one serial
communication port for sending downloading the code with the SiLabs IDE and one serial communication port to send and receive text
information with Hyperterminal. Since most of the
student laptops (and some of the lab computers) have only one serial
communication port, we will need both partner’s laptops, or one laptop and the
lab computer to run the necessary software. It is recommended that a student
laptop be used for compiling and downloading code. Connect the serial cables to
the C8051 as shown below (note colored circles with colored text above) and
then to the appropriate computer COM ports.



If you have properly
installed all the necessary software as described in the CD-ROM
Installation Guide for SiLabs IDE Software link,
you will have an icon for the c8051.ht Hyperterminal
communication link on your desktop (or elsewhere if you chose a different
destination). On the computer that will be used to receive information from the
C8051 microcontroller, double-click this icon to begin the communication link.


Once the program begins, it
will automatically attempt to establish a connection. You may disconnect this
connection by selecting “Disconnect” in the “Call” menu or clicking the
“Disconnect” icon. If you need to change any settings, you should disconnect the
call.

The first time you use this
software, you should check the properties for this communication link. Under
the “File” menu, choose the “Properties” menu.

The microcontroller will
send output information through the serial connector that is found on the
microcontroller board. It will receive the downloaded code and keyboard input
through the serial adaptor that is found strapped behind the microcontroller.
For use on an RPI laptop,
the software should connect using COM1. The desktop computers in the lab can
use COM1 or COM2. On the back of the desktop computer, the serial connector
that is closer to the side edge is COM2, and the other serial connector is
COM1. Make sure the software properties are set to receive information from the
correct COM port.
Note: To change the COM
port and settings, the connection must be disconnected. When starting the
software, it will automatically establish a connection.

Click on the “Configure”
button on the Properties menu beneath the COM port selection. The COM port
properties should be set for 57600 bits per second, 8 data bits, no parity
bits, 1 stop bit, and no flow control. Click “OK” on both menus to close them
with any changes saved.

To establish a connection,
select “Call” under the “Call” menu, or click on the “Call” icon. Once the
microcontroller is running software, any screen outputs will appear in this
software screen.

If you already have the C
code typed into a file (make sure it has a .c extension with no additional
periods or any spaces in the file name or file path), put a copy of this file
into the “C:\SiLabs\MCU\Projects” folder that you created previously on the
computer that will be used to compile and download the code to the
microcontroller.

On the computer that will be
sending information to the microcontroller, start the SiLabs
IDE software from the link in the “Start” menu.

When the software begins,
open your C code file.

Under the “Project” menu,
choose to add your file to the current project. It will prompt you for a
project name, which you may choose.

If the code is ready, you
may compile the code and check for syntax errors using the “Assemble/Compile
File” icon or option in the “Project” menu.

If your code is free of
syntax errors, the compilation will be successful. If there are errors, clues
to help you fix them will be given in the bottom screen.
Once your code is free of
syntax errors, choose the “Build/Make Project” icon or option in the “Projects”
menu.

In order to send your code
to the microcontroller, you need to establish a connection with it. Choose the
“Connect” icon or option in the “Debug” menu to make this connection.

Now send the compiled code
to the microcontroller by choosing the “Download Object File” icon or option in
the “Debug” menu.

Once your code has finished
downloading, it can be started by choosing the “Go” icon or option in the
“Debug” menu.

If your code was written
correctly, it will begin running, and you can observe the results. The code will continue to run until the
program ends or until the “Stop” icon is chosen. You may also debug your code
using the “Step,” “Step Over,” and “Run to Cursor” options in the “Debug” menu.