Section 2 - Hyper Terminal
Downloads
|
File |
Instructions |
|
Copy files to the HelloWorld directory on your U: drive |
|
|
Open the file rather than saving the file to directly use the file |
Step 1 - Open HyperTerminal
Directly loading HyperTerminal
Click on the PowerPC.ht file. Open the file directly rather than saving the file to disk.
Running HyperTerminal from a saved file
From the Windows desktop, select the following options:
Start à Accessories à Communications à HyperTerminal
When HyperTerminal first loads, you will be
prompted to select an icon for the connection. Click the Cancel button to
skip creating a new connection. Click Fileà
Open from the HyperTerminal menu. Open the PowerPC.ht
in HyperTerminal.
HyperTerminal will be used in Cpr E 211 for display to the PC. The program will also be used to send text files to the PowerBox for use in later labs. For now, you will simply be using the program to demonstrate how to send information to the desktop PC via the serial port. All of the options are set correctly in the PowerPC.ht file for connecting to the PowerBox. Click here to see a view of the PowerBox and the types of communications that it uses.
Once you have opened the PowerPC.ht file, HyperTerminal uses the information in the file to determine the correct settings. For lab, the PowerBox is connected to the desktop PC on COM2 at 9,600 bps.
Step 2 - Modify HelloWorld to add in support for PC communication
Next, you will be adding several C
files to the HelloWorld project in order to communicate with the desktop PC.
If you click on the Serial Source Code (UART) file group in the
HelloWorld project, you will see various C source and header files
listed. For most designs in industry, the actual C and assembly code will
be split into multiple files in order to make the design easier to manage.
In addition, it allows you to reuse previous code for newer projects without
entirely rewriting the code.
For this case, you will be adding to
the project two C files that have already been written (Serial_PC.c and
Serial_PC.h). The header file lists the function prototypes for #include
in other files, and the C file contains the actual source code. Now, add
the two files to the Serial Source Code (UART) group by clicking on Project
à
Add Files.
Place
the two C files into the HelloWorld directory with the other C files. The
files will appear at the bottom beneath all of the folders. Drag the two
files into the Serial Source Code (UART) group. Now, you should
see the two files in the HelloWorld project in the Serial Source Code (UART)
group.
Press F7 to have CodeWarrior compile your code. The new source code should compile without a problem. Make that you have included both Serial_PC.c and Serial_PC.h into the project.
Step 3 - Modify main.c to send output to the PC
Double click on Serial_PC.h to open the file. Notice the
four function prototypes in the file. The two functions that you are
interested in for the lab are PC_Init and PC_PutString.
Notice how the functions are extremely similar to the LCD functions.
Now, write and insert the necessary C code into the main.c code to send the message "Testing the serial connection" across to the PC; also send the date and time of your lab section.
You will need to use PC_Init and PC_PutString to initialize the serial port and send a string to the PC. What happens if you only use a /r in your code? Consider the definitions for /r and /n
/r - Carriage Return - Take the cursor back to the left-most position
/n - Line feed - Drop the cursor down one line
Try running your program with various combinations of /r and /n and observe the effects. (Hint: You may see this again on a quiz or exam.)
Compile and run your program using Ctrl+F5.
Look at the HyperTerminal and you should see
the text you just printed appear on the HyperTerminal. Note that the text
from the previous section should still appear on the LCD. Show this to
your TA after you are done.