COFFEEPOT device control basics |
In laboratory 2 we are going to make use of a "virtual hardware I/O device" in order to show some simple programming techniques. Just how good is a "virtual device" to demonstrate these ideas?
Motorola runs a series of courses through "Motorola University" which make heavy use of simulations. A question to ask is "how good are those simulations"? A paraphrase of what the course book states is
A "virtual device" simulation is not meant to be an accurate representation of what the device "does". It is meant to be an accurate representation of what a programmer has to "do" to make the device operate.
You are not going to actually be able to smell the coffee perking when using the COFFEEPOT virtual device. Instead, what you are going to be able experience is the typically activities associated with generating the code necessary for computer control of a device -- embedded applications.
The following is the pseudo-code (code concept) that is needed for laboratory 2 and the control of the COFFEEPOT. You are required to generate the assembly code to perform these operations. For information on loop control see the while loop information or the explanation on loop control in HVZ.
Place_COFFEEPOT_on_DATA_BUS INIT_COFFEEPOT while (temperature < BOILING) Apply_Heat end_while Signal_Water_Boiled while (time < TOO_LONG) Apply_Low_Heat end_while Signal_Coffee_Ready
As with any device, it is necessary to look up the data sheets for the COFFEEPOT device. From this sheet we can see that this device has a number of built in registers. By writing commands to these registers, we can control the activity of the device.
The COFFEEPOT device registers have the following common characteristics.
Every device on a processor's data bus must have a unique base address to ensure that the processor's signals go to the correct device. The base address for the COFFEEPOT device is 0x20000. Later on we shall see how it is possible to connect a number of different devices to the simulator's "buses". HVZ discuss "Input-Output Organization" in Chapter 4.
The following "data sheet" information shows the mnemonic (name), offset, and method of control for each of the COFFEEPOT registers. This information can be automatically specified by placing the COFFEEPOT include file cof020.i into our source code.
Mnemonic | Offset | Allowable Values |
Functionality |
---|---|---|---|
C_HEAT | 0x00 | 0 -- 25 | Determines the amount of heat applied to the COFFEE. If this register is not continually written to, the COFFEE water never boils nor does the COFFEE perk |
C_TEMPERATURE | 0x10 | Read only | Current water temperature |
C_CONTROL | 0x20 | RESET (0x8000) | The Control Register is used to set the processor into a known state after "power-up". On the TRAIN and TV devices it also provide information about whether the device is ready for read/write operations |
C_WATER | 0x30 | STARTWATER (10) CLOSEWATER (0) |
Opens the water valve Closes the water Valve |
C_TIMER | 0xE0 | Read only | Elapsed time (in TICS) since the COFFEEPOT powered up |
C_SCANREGISTER | 0xF0 | DEBUGMODE_NOWAIT (2) | Debug register -- on prototype device only |
These "data sheets" indicate possible values that can be sent to the virtual device to cause it to perform useful tasks. For example, writing the STARTWATER value (10) to the C_WATER register will cause the COFFEEPOT device to open the valve that allows (virtual) water to enter the brewing chamber. To avoid flooding the laboratory, the valve should be closed after a certain elapsed time. This time can be measured by accessing the C_TIMER register.
![]() |
Last modified: July 22, 1996 01:06 PM by M. Smith.
Copyright -- M. R. Smith