Hardware Reference
In-Depth Information
5. Output the current temperature to the screen in the following format:
Current temperature:
xxxxºF yyyy.yºC
6. Output the next message:
Want to continue? (y/n)
7. Call the getchar() function to read in one character. If the character entered by the user
is y, then repeat the process. Otherwise, return to the D-Bug12 monitor by executing
the swi instruction.
Note: The ASCII code of the degree character 8 is 176 (or $B0).
L4.3 Seven-segment display shifting. Write a program to display the following patterns on the
four seven-segment displays on the Dragon12 demo board (or any other demo board) with each
pattern lasting for half of a second:
1234
2345
3456
4567
5678
6789
7890
8901
9012
0123
The patterns will be displayed continuously.
L4.4 Three-tone siren generation. Write a program to generate a three-tone siren using the PT5
pin with each tone lasting for half of a second. The frequencies of these three tones are 200 Hz,
500 Hz, and 1 kHz.
L4.5 I/O Routine application and time-of-day display. The complementary CD includes a fi le
that contains a set of I/O subroutines that you can call. By adding the fi le stdio0.asm to your
program (using the “#include c:\miniIDE\stdio0.asm” statement), you can output a string to the termi-
nal window and read a string from the keyboard.
Study the subroutines contained in stdio0.asm and write a program to perform the follow-
ing operations:
1. Output a message by calling printf() (or the supplied subroutine puts) to ask the user
to enter the current time in the format of hh:mm:ss using the PC keyboard (include
the colon character).
2. Read in the time of day by calling the gets subroutine and store the time of day in a buffer.
3. Display the time of day in the format of “Current time is hh:mm:ss” where hh, mm,
and ss are the time components that you just entered.
4. Wait for one second and update the current time-of-day stored in the buffer.
5. Backspace eight places (write a loop and call the putch subroutine to output the
backspace character).
6. Redisplay the new time of day.
7. Go to step 4.
 
Search WWH ::




Custom Search