Quote Originally Posted by richard View Post
that last line was wrong should be


day = ((reg_val[3] >> 4) * 10) + (reg_val[3]$0f) ; bcd2bin conversion

lcdout dec2 day

must have been too early in the morning for me

It took me a moment... I'm blaming it on mashed potato poisoning - self inflicted, don't call the police.


In fact, I use a similar function to convert the calendar registers to decimal (and back) as part of each read and write routine. The problem comes in trying to use that decimal value to retrieve text characters. The math:

REG_VAL[5] = 1 in January... So:

READ 097 + (REG_VAL[5] * 3) + 0 = DATA position 100; CA_MONTH[0] = "J"
READ 097 + (REG_VAL[5] * 3) + 1 = DATA position 101; CA_MONTH[1] = "A"
READ 097 + (REG_VAL[5] * 3) + 2 = DATA position 102; CA_MONTH[2] = "N"

The problem... On the LCD the first character in munged - displays as "$AN", where $ represents some random pattern of dots. When REG_VAL[5] = 2, I get $EB; 3 = $AR... Indicating that the month is correctly decoded and the DATA located properly. As they say, "Everything is perfect, it just don't work".

The day (MO, TU, WE...) is decoded similarly from REG_VAL[3] (starting at DATA location 137) and displays as it should.