
Embedded Real-Time System Programming
Lab Exorcise 1:
This exercise is to be done in groups of two. You will probably want to search the example programs for help.
1. Write a program in C that uses the 8 LED’s:
You can use the method: void putleds ( unsigned int i);
2. Write a program that uses the 8 Dip Switches:
You can use the method: unsigned int getdipsw ();
3. Write a program that uses the 4 7-segment LED’s:
You can use the method: void putdisp ( unsigned int i);
{the display expects a 4 digit Binary-Coded-Decimal number}
4. Write a program that uses the A/D converter as an output device:
a. See the MCF5282 User’s Manual (There is a link in the Platform Hardware document) Sections 27.4 & 27.6
b. Set the sim.qadc.ddrqa Port A Data Direction Register for pins 0,1,3, & 4 to be digital outputs
c. Set the outputs with sim.qadc.portqa Port A Data Register
d. Use the Oscilloscope to observe the output (s). (See the Schematics in the Platform Hardware document)
{ PLEASE BE VERY CAREFUL using the scope probes! We don’t want to sacrifice any NetBurners}
5. We now want to exercise the A/D converter in it primary analog conversion mode. Attached is a sample program. It is
similar to the one supplied with the NetBurner. I made a few changes to “clean it up”. We will use it to understand how the A/D
converter is set-up and used in its basic primary mode.
• Find the functionality provided by :
#include <..\mod5282\system\sim5282.h>
and describe how it defines the object variables used to program the A/D converter.
• Become familiar with the program. Confirm that the set-up of the A/D converter makes sense. In you report, you should
explain the settings used.
• Run the program and confirm that it produces the output you expected. Don’t put any inputs on the 8 A/D channels yet.
Observe the outputs and explain what you observe.
• Put 0 volts (gnd) or 5 volts on one A/D inputs and observe the value in the output. Put the voltage (0 or 5 volts) on other
A/D inputs and observe that the A/D values are appropriately displayed in the output.
• RECHECK THE RAMP WAVE ON YOUR FUNCTION GENERATOR AND HAVE YOUR LAB PARTNER
CONFIRM THAT IT IS CORRECTLY SET (1 volt to 4 volt swing). IT IS IMPORTANT THAT YOU NEVER
PLACE A NEGATIVE VOLTAGE OR A VOLTAGE GREATER THAN 5 VOLTS ON AN A/D INPUT! Keep the
waveform displayed on your scope.