55:036
Embedded Systems and Systems Software
Spring, 2007
Sixth Laboratory Assignment
Due Dates:
Prelab: Tuesday,
April 3
Lab Report: Thursday, April 19 (completed labs must be demonstrated and signed-off no later than Tues., April 17)
Objective:
The purpose of this lab is to gain experience with asynchronous I/O (RS-232), serial bus interfaces, intelligent peripheral chips, and the design and implementation of reasonably complex embedded systems.
Lab Description:
The software for this lab is to be written in
Microchip C18 C. You will build a
simple time clock, using your QwikFlash board, the mag-stripe reader
introduced in lab 5, and an external real-time clock chip.
Employees will "clock in" and " clock out" by swiping their IC
card through the time clock's mag stripe reader. Each time an ID-card is swiped, the time-clock will
determine the current time and date and will send a message of one of
the following forms to the screen of the terminal attached to the
RS-232 port of the QwikFlash:
Employee 1234567890 Clocked In at
10:32:35 AM on Fri. 03/30/07
or
Employee 1234567890 Clocked Out at 4:53:53 PM on Sun. 04/01/07
The system will use a
DS1305 Serial Real-Time Clock chip for timing functions. The
DS1305 will be interfaced to the PIC via
SPI. The SPI pins of the PIC can be
accessed via the H2 expansion header on your QwikFlash
Board. The “toolbox” at each lab station contains a small proto-board
and a
ribbon-cable for connection between the proto-board and the QwikFlash
expansion header. The DS1305 chip and associated components will be
available
in the lab. The data sheet for the
DS1305 is posted on the class web-site (under the Supplementary
Materials link).
When the time-clock system is idle, the LCD Display on the QwikFlash
Board should dislpay the following message:
SWIPE
CARD
After a card has been swiped, the LCD message should switch for 5
seconds to:
THANK
YOU
In addition to displaying "clock-in/"clock-out" informaiton, the RS-232 interface will used to set/adjust the current date/time maintained by the DS1305. At any time, the current date and time can be changed from the terminal interface. Here is the nominal message exchange between the person changing the time (typing at the terminal keyboard) and the time-change system (displaying information on the terminal screen). Text shown in BOLD is typed by the keyboard user. Non-bold text represents responses by the time clock system:
T
Time Change Requested:
Enter Hour (Two digits): 07
Enter Minutes (two digits): 46
Enter Seconds (two digits) : 53
Enter 0 for AM, 1 for PM: 1
Time changed to 07:46:53 PM
D
Date Change Requested
Enter Day(1-7):6
Enter Month (two digits): 03
Enter Day (two digits): 30
Enter Year (two digits): 07
Date changed to: Fri. 03/30/07
Requests to change the time and/or date can be made at any time.
Of course, the requested changes should be used to update the current
time/date in the DS1305 chip, accordingly.
Note that although the DS1305 has a battery backup feature, you do not need to implement this in your design.
Prelab:
Carefully review the class lecture notes and read Chapters 15 and 18 in the text to fully understand the basics the basics of SPI and asynchronous serial I/O. In addition, carefully read the data sheet for the DS1305 Real-time Clock chip to understand its functionality and operation. Finally, review the C18 C Compiler Libraries documentaiton for the SPI funcitons (Section 2.8) and USART functions (Section 2.10):
Carefully design your solution to the lab using flow-charts and/or pseudo-code. Do not start writing c code until you FULLY AND COMPLETELY UNDERSTAND the solution.
To be submitted on Tuesday, April 3: Pre-lab report in the format specified in the Laboratory Guidelines document. The pre-lab report should include a flowchart and/or pseudo-code code description of your algorithm and a copy of your initial source code.
Lab Report:
Your lab report (due on Thursday, April 19) should follow the general format described in Laboratory Guidelines document.
Some Important Considerations:
1. Be systematic. There are several new objectives to be mastered. Try to divide the prolem up into pieces that can be soled more-or-less independently. When you have the pieces written you can start to put them together to achieve the final objective.
2.
You will not be able to use QwikBug
to download and run your program since it will interfere with the
RS-232
communications in your program.
You will need to use either the device programmers in the lab or
a
separate boot-loader to program the PIC.
A 10 MHZ bootloader is available on
the class
website for those who want to use it (The link is password-protected. Ask the instructor if you need to access the bootloader). Note
that any use of the device programmer, either to download your program
or load
the bootloader, will destroy the QwikBug
monitor on your PIC chip. We should be
able to reinstall QwikBug later. However, to be safe, you may want to use a
separate 18F452 chip. Also, be sure to remove the "QB BREAK"
jumper on your QWIKFLASH board when using RS-232. Don't lose the
jumper. You will need to reinstall it in order to use QwikBug
again.