Program Description

Here are some notes on the clock firmware:

Timer begins at 0xc4 and interrupts at overflow. TMR0 and Global Interrupts are set. Timer0 is increment on leading edge of TOCKI. The WDT is cleared at the end of the main loop.

0x0 -> TRISC All bits of Port C are used as output.

0x0 -> TRISB Port B is currently Unused.

b'10000' -> TRISA The TMR0 bit must be an input. Otherwise PORTA is set to output and currently unused.

Output: In each case, bit 7 is the hour/not minute flag and bit 6 is the binary/not 7-seg flag. With binary, the remaining bits are the binary representation of the time, either minutes or hours. With the 7-seg, bit 5 is unused and the low nibble is the hex address of the segment to be turned on. I use dual 7-seg displays, the 8-segs(including decimal) are addresses 0-7 and the left are 8-15.

Reserved memory locations

  1. endOfNamedSpots (20h) This is where I keep track of the last reserved memory spot. Just in case it comes in handy some day. INDF use maybe?

  2. output (21h) This is the value to be sent to the the output port

  3. counter (22h) This is for counting the number of times I move through the main loop.

  4. tmp (23h) Temporary memory slot

  5. myStatus (24h) My Status byte (see above)

  6. saveW (25h) I use this to save the W register value when I have an interrupt

  7. minutes (26h) Minute memory location

  8. hours (27h) Hour memory location

  9. currSeg (28h) I use this when I iterate through the 7-seg segments

  10. valueToLatch (29h) This contains the current value sent to the Hex-16 latch

  11. totalMinutesLOW (30h) Total minutes since start of timer. why not? might come in handy later

  12. totalMinutesMIDDLE (31h) Middle of a 3byte counter of total minutes

  13. totalMinutesHIGH (32h) End of total minutes segment. increment LOW, if carryover increment middle, if carryover increment high. if carryover... whoa!

  14. setTimeTmp (33h) Not yet implemented to be used for setting time

My Status Register

Return to Categories