Ds1302 readburst & gosub/return
hmlittle59
Posts: 404
Hello All
I've been using this DS1302 Demo code(Stripped down to fit my needs) for over a year now and it works. I'm only using the 24hr format. But now I want to only read the values "ReadRTCBurst", and do a comparison with them. But after 3 days of trying to find a bug it appears to be with the way I'm trying to get the time values. The one on the wall works great, no problem, but this expanded version of my code showed up when I went 3 deep with my GOSUB/RETURN and needed to get the time values and there appears to be NO RETURN values on the STACK. What am I doing wrong in the way I'm reading the values from the DS1302? The DEBUG "CAT", allowed me to track it down to this "GOSUB" routine. With the "CAT" code in place it RETURNed to the Main Menu, without it and "ReadRTCBurst" in place the BS2e crashed every time.
1) I'm 3 deep with GOSUB and this routine CRASHES the STACK(RE-Boots)
2) Did I leave out some COMMAMDs when doing this READ?
3) Why does this routine work as is but not with (GOSUB ReadRTCBurst)
4) I must have forgotten to turn something on...What I don't know?????
thanks for any help
[noparse][[/noparse]code]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
I've been using this DS1302 Demo code(Stripped down to fit my needs) for over a year now and it works. I'm only using the 24hr format. But now I want to only read the values "ReadRTCBurst", and do a comparison with them. But after 3 days of trying to find a bug it appears to be with the way I'm trying to get the time values. The one on the wall works great, no problem, but this expanded version of my code showed up when I went 3 deep with my GOSUB/RETURN and needed to get the time values and there appears to be NO RETURN values on the STACK. What am I doing wrong in the way I'm reading the values from the DS1302? The DEBUG "CAT", allowed me to track it down to this "GOSUB" routine. With the "CAT" code in place it RETURNed to the Main Menu, without it and "ReadRTCBurst" in place the BS2e crashed every time.
1) I'm 3 deep with GOSUB and this routine CRASHES the STACK(RE-Boots)
2) Did I leave out some COMMAMDs when doing this READ?
3) Why does this routine work as is but not with (GOSUB ReadRTCBurst)
4) I must have forgotten to turn something on...What I don't know?????
thanks for any help
'********************************************************************************** ReadRTCBurst: ' Read all time-keeping registers in one burst ' DEBUG " CAT":PAUSE 1000 ' RETURN HIGH RTCCS SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2] SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Day,Year] LOW RTCCS RETURN ' '********************************************************************************** ' 'Print short date format on LCD screen...mm/dd/yy '********************************************************************************** PrintDate: GOSUB ReadRTCBurst SEROUT LCDScreen, Baud, [noparse][[/noparse]LcdLine2,HEX2 Month, "/", HEX2 Date, "/", HEX2 Year ] '********************************************************************************** 'Print 24-hour time format on LCD screen...hh/mm '********************************************************************************** PrintTime: SEROUT LCDScreen, Baud, [noparse][[/noparse]LcdLine2+11,HEX2 hours, ":", HEX2 minutes] 'Display Hrs/Mins ' =============================================================== ' ------------------ Print Abbreviated Day of week ---------------- ' ============================================================== PrintDay: SEROUT LCDscreen, Baud, [noparse][[/noparse]LcdLine1+13] ' LCD Home Position + Off set LOOKUP (day - 1), [noparse][[/noparse]Sun, Mon, Tue, Wed, Thu, Fri, Sat], work DO ' Display Day Abbreviation READ work, idx ' Read Each Character Into idx IF (idx = 0) THEN exit_PD ' If 0 then done with day SEROUT LCDscreen, Baud, [noparse][[/noparse]idx] ' Send Character To LCD Display work = work + 1 ' Increment Address LOOP ' Next Character, If 0 Then Done exit_PD: RETURN ' Back to call routine '
[noparse][[/noparse]code]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
Comments
Just read the help file and did an exact count and I'm over the limit. DAG.
Back to the DRAWING Board...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59