So, I have been working on a controller for my aquarium - to turn on lights, control temperature... The project progresses well and a fair number of the features work flawlessly; however a couple of unrelated issues - some PicBasic related and some not - continue to plague me. I'm hoping for some help...
First, I use a RTC1307 clock module to track time. Each five seconds and each one minute, routines run to update the display and to adjust various parameters. A part of the output is to display the time and date in the format: TH, NOV 27, 14. I store characters in DATA statements and, using the clock registers and READ statements, compose the required strings with the following code:
'-----SET CALENDAR
EXPAND_DATE:
READ 097 + (reg_val[5] * 3) + 0, CA_MONTH[0]
READ 097 + (reg_val[5] * 3) + 1, CA_MONTH[1]
READ 097 + (reg_val[5] * 3) + 2, CA_MONTH[2]
READ 137 + (reg_val[3] * 2) + 0, CA_DAY[0]
READ 137 + (reg_val[3] * 2) + 1, CA_DAY[1]
RETURN
These are the associated DATA statements:
DATA @ 100, "J", "A", "N", "F", "E", "B", "M", "A", "R", "A", "P", "R", "M", "A", "Y", "J", "U", "N", "J", "L", "Y", "A", "U", "G", "S", "E", "P", "O", "C", "T", "N", "O", "V", "D", "E", "C"
DATA @ 137, "S", "U", "M", "O", "T", "U", "W", "E", "T", "H", "F", "R", "S", "A", "S", "U"
And here is the code that puts it together on the 4X20 LCD operating in 4-bit mode:
'-----UPDATE DISPLAY
UPDATE_DISPLAY:
'-----LINE1
LCDOUT $FE, LINE1, CA_DAY[0], CA_DAY[1], ", ", STR CA_MONTH[0]\1, STR CA_MONTH[1]\1, STR CA_MONTH[2]\1, " ", dec2 REG_VAL[4]
REG_VAL[3] is the day of the week, REG_VAL[5] is the month and REG_VAL[4] is the 2 digit year. CA_DAY is defined as a byte array [2] and CA_MONTH as a byte array [3]; LINE1 a constant representing position 1 on the first display line.
Everything works as expected, EXCEPT that the fist day of the month, any month, is always munged - appearing as some unintelligible pattern of dots rather than the first day of the month. It is hard to demonstrate because the pattern of dots is not one defined on the keyboard, but similar to $OV - where "$" would be a scatter-shot of dots. Changing the month, it might be $AN or $EB... Always the first character of the month. The two character day appears as expected (even without the string designator) - added to the month without beneficial effect.
I've tried PAUSING between reads, reversing the order of the reads... no difference. I've verified the function of the LCD by moving the date to the second line - items on the first line display properly - the date, on the second line, remains munged in the same way as before.
Anyone see the issue?
Bookmarks