Download PIC Alarm Clock

Transcript
PIC MAXI ALARM Developer’s Guide
John Tooker PIC18F4550 Implementation
MT_MD_Change_q takes a code as an argument, and based on that code responds differently when certain
switches are pressed. This list of codes in this function’s description (page $$).
Alarms
There can be up to 32 alarms in the processor stored on a stack, starting at Alarm_Base_addr. Each alarm
can ring once or every day (initially we wanted to be able to ring certain days of the week, but this was never
accomplished, but still achievable). Alarm can be set to the minute, and will ring when seconds go from 59 to
00. Alarms ring only when the date they are set to matches the current date (and the time matching too). This
means when setting an alarm, you set the date to the first time you want the alarm to ring. But as you will see
below, we can only store one date per alarm, so how to have that alarm repeat?
There is also a modification stack for the alarms, starting at Alarm_Mod_Base_addr with entries corresponding
to entries in the alarm stack. When an alarm rings, we look at its corresponding modification data to see if we
need to repeat or not, if we need to repeat, we alter the alarm’s date so that it rings the next time (as of now,
this is updating the date to ring the next time). This will be described a little better below.
Exceptional Alarms
We have two exceptional alarms: the daily alarm and the snooze/nap alarm. These are located at the base of
the stack, and each is modified outside of the normal alarm modification routine, in fact, they are not even
viewable with the rest of the alarms (page 25).
The daily alarm’s modification data says that it will ring the next day, but can be turned off through a separate
routine (state33 on page $$) and viewed and altered easily (states 03, 13 pages $$, $$).
The snooze alarm is never seen by the user, and is set based on the current time plus the default snooze time
when the snooze button is hit (while alarm is ringing), or we enter nap mode (page $$). It is not modified after
it rings.
All the other alarms are called ‘special alarms’
Data Structure of an Alarm
4 bytes, each in compact BCD form.
date [high]
date [low]
hours
minutes
modification
value [low]
used as
temporary
storage
modification
code
Structure of an Alarm Modification
4 bytes in varying forms.
modification
value [high]
5/19/08
Page 19 of 64