SX/B code for DS1302
MikeS
Posts: 131
Does any one have a SX/B program for the DS1302?
I have successfully combined the SX/B SEROUT example that uses the BPI-216 LCD and the SX/B Example Project that uses the DS1620 to display temperature on a serial LCD using the SX. I would like to add the ability to display time also.
In the Basic Stamp code that·I use for the DS1302 there are nibble·variables for secs., mins., and hrs. I am not sure how to handle these because· SX/B can only handle byte variables.
thanks
Mike S.
I have successfully combined the SX/B SEROUT example that uses the BPI-216 LCD and the SX/B Example Project that uses the DS1620 to display temperature on a serial LCD using the SX. I would like to add the ability to display time also.
In the Basic Stamp code that·I use for the DS1302 there are nibble·variables for secs., mins., and hrs. I am not sure how to handle these because· SX/B can only handle byte variables.
thanks
Mike S.
Comments
seconds, minutes, and hours are byte variables.
01 secs is a low nibble of sec
10 sec is a high nibble of sec
01 min is a low nibble of min
10 min is a low nibble of min
01 hrs is a high nibble of hrs
10 hrs is a low nibble of hrs
Mike S.
I am assuming your LCD takes data in ASCII format.
To translate the lower nibble into ASCII, make a copy of the data, AND that copy with $0F, then add $30 to the value, the result is that digit in ASCII.
To translate the higher nibble into ASCII, make a copy of the data, perform SWAP, AND that copy with $0F, then add $30 to the value, the result is that digit in ASCII.