
Originally Posted by
Dennis
Ok but I have read in a lot of posts regarding the DS1302 and BCD conversion ..does this still apply ?
If you use a push button to increment the minutes (or hours, etc) you will run into a problem because of the BCD.
This subroutine increments the minutes by 1 every time it's called.
It does the BCD to decimal conversion, increments the minutes, then converts the new number back to BCD before setting the time.
Code:
increminute: 'subroutine to do BCD to decimal conversion, increment and convert back to BCD
mathtemp =(rtcmin>>4)*10+(rtcmin & $0F) 'convert BCD minutes into Decimal minutes
mathtemp=mathtemp+1 'increment by 1
If mathtemp>59 then 'If minutes exceeds 59
mathtemp=0 'reset to 0
endif
rtcmin=((mathtemp DIG 1)<<4)+mathtemp DIG 0 'convert Decimal back to BCD
rstcount = 0
gosub settime
return
steve
Bookmarks