| ??? 10/24/05 04:57 Read: times |
#102794 - SBC hardware clock software error |
The 8052.com SBC hardware clock program fails to show the month name for months 10, 11, 12. The month name routine erroneously treats the BCD month number provided by the DS1307 as hex. I added the following lines to the routine following the DEC A line.
.
.
;Display Month
MOV DPTR,#MonthNames ;Point to the month name table
MOV A,R2 ;Get month (1-12)
DEC A ;Now month is (0-11)
(insert below lines)
CJNE A,#09,Not09 ; Is Acc greater than 9?
SJMP NoAdj ; If ACC = 09 no adjustment needed
Not09:
JC NoAdj ; If Acc < 09 no adjustment needed
CLR C ; prepare for subtract
SUBB A,#06 ; adjust BCD to hex
NoAdj:
(continue with existing code)
CLR C ;Make sure carry is clear
RLC A ;Multiply by 2
RLC A ;Multiply by 4
ADD A,DPL ;Add low byte of DPL
MOV DPL,A ;Update value of DPL
MOV A,DPH ;Get value of DPH
ADDC A,#00h ;Add high byte
MOV DPH,A ;Update value of DPH
LCALL SendLCDString ;Display "Jan", "Feb", etc. on LCD
MOV A,#' ' ;Send a space
LCALL SendLCDText ;Send the space
.
.
.
Hope this helps others having the same problem. I'm confident there are more streamlined and really neat ways of doing this better, but it works for me. Hal |



