View Full Version : DS1302 ask for and input load chip
RobbCJohnson
- 20th December 2017, 01:33
All my code works but how do I substitute $30 with my TEMP
one of my request to get start information:
SEROUT2 TX, baudrate, ["ENTER HOUR (HH):",13]
SERIN2 RX, Baudrate, [DEC2 TEMP]
writing it to the ds1302:
HIGH RST ' Activate the DS1302
SHIFTOUT DG, CLK, 0, [$84] ' Send write hour
SHIFTOUT DG, CLK, 0, [$30] ' Send hours
LOW RST
tried a lot of different solutions , but none worked
thanks for the any help
Robb
RobbCJohnson
- 20th December 2017, 12:26
thanks to Jamie s This works
SEROUT2 TX, baudrate, ["ENTER HOUR (HH):",13]
SERIN2 RX, Baudrate, [DEC2 TEMP]
RTCHH=TEMP DIG 1
RTCHH=RTCHH<<4
RTCHH=RTCHH+(TEMP DIG 0)
'writing it to the ds1302:
HIGH RST ' Activate the DS1302
SHIFTOUT DG, CLK, 0, [$84] ' Send write hour
SHIFTOUT DG, CLK, 0, [RTCHH] ' Send hours
LOW RST
Dave
- 20th December 2017, 14:00
I believe you need to treat the data as Binary Coded Decimal, However if you enter the data as 2 digits of hexadecimal that should work. Just don't enter any alpha digits, ie. ABCDE or F. Try replacing the lines:
SERIN2 RX, Baudrate, [DEC2 TEMP] with SERIN2 RX, Baudrate, [HEX2 TEMP]
and
SHIFTOUT DG, CLK, 0, [$30] ' Send hours with SHIFTOUT DG, CLK, 0, [HEX2 TEMP] ' Send hours
richard
- 20th December 2017, 21:52
SHIFTOUT DG, CLK, 0, [HEX2 TEMP] ' Send hours
will not work
the value needed to be sent is a packed bcd byte not two hex chrs
consideration also of the 12/24 hour bit must be considered also
simple way to convert binary hour value in tmp to packed bcd in hour
HOUR = ((tmp / 10) << 4) + (tmp // 10) ; bin to bcd
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.