SEROUT command and Serial LCD must be present in order for program with an INTE
T&E Engineer
Posts: 1,396
OK...After going through·my LED matrix program using a DS1302 RTC·and trying to clean it up I have one very weird occurance.
It seems that I must have a SEROUT command anywheres after the Start: label. It doesn't matter what pin nor legal baud rate is setup for it. Also it needs to be connected to a Serial LCD. Any defined pin in the SEROUT command can be used. BUT, I can also disconnect either the +5v or the GND and it will work. If I remove both then the program does not (e.g. remove the entire serial LCD).
Here is what I am seeing:
The program first scrolls through the Time on the top set of the LED matrix·and then it scrolls the Date on the bottom set of the LED matrix. All is correct. However, the second time it scrolls through, the Time changes from it's set time of·11:59:50 PM to 00:00:01 PM··· NOT the·expected 12:00:05 AM (as it takes·15 seconds to go through it's cycle). The Date also is off too.
If I connect the RA pin and either ground or +5V (or both ground and +5v)...to the LCD display and reset power to the SX52, then all works fine meaning that the Time changes from it's initial 11:59:50 PM to 12:00:05 AM and the date is good too.
Why does it need to have a SEROUT and LCD connected to get the updates in Time and Date to work? This doesn't make any sense. It's is almost like the LCD is sending it a signal (even though it only needs as a minimum·RX and·+5v (or RX and gnd) to work.
Any ideas?·I'm wondering if it is related to the INTERRUPT for the LED Display. The SEROUT was originally in place as a SENDBYTE routine. However, I can have a command such as SEROUT RA.5, T2400, 0 and it will work as long as I have the LCD connected via RX (to RA.5 or what ever pin is defined) and either ground or +5v going to the LCD.
The SEROUT command can be pretty much anywhere's after the START:·label and must have either +5v or ground and the RX pin connected to the serial LCD.
The Time and Date does not get updated correctly if·the SEROUT command·is located before the START: label.
I haven't got a clue on this one. Although I think it could be·INTERRUPT related.
I have attached the program if anyone can help.
Thanks.
It seems that I must have a SEROUT command anywheres after the Start: label. It doesn't matter what pin nor legal baud rate is setup for it. Also it needs to be connected to a Serial LCD. Any defined pin in the SEROUT command can be used. BUT, I can also disconnect either the +5v or the GND and it will work. If I remove both then the program does not (e.g. remove the entire serial LCD).
Here is what I am seeing:
The program first scrolls through the Time on the top set of the LED matrix·and then it scrolls the Date on the bottom set of the LED matrix. All is correct. However, the second time it scrolls through, the Time changes from it's set time of·11:59:50 PM to 00:00:01 PM··· NOT the·expected 12:00:05 AM (as it takes·15 seconds to go through it's cycle). The Date also is off too.
If I connect the RA pin and either ground or +5V (or both ground and +5v)...to the LCD display and reset power to the SX52, then all works fine meaning that the Time changes from it's initial 11:59:50 PM to 12:00:05 AM and the date is good too.
Why does it need to have a SEROUT and LCD connected to get the updates in Time and Date to work? This doesn't make any sense. It's is almost like the LCD is sending it a signal (even though it only needs as a minimum·RX and·+5v (or RX and gnd) to work.
Any ideas?·I'm wondering if it is related to the INTERRUPT for the LED Display. The SEROUT was originally in place as a SENDBYTE routine. However, I can have a command such as SEROUT RA.5, T2400, 0 and it will work as long as I have the LCD connected via RX (to RA.5 or what ever pin is defined) and either ground or +5v going to the LCD.
The SEROUT command can be pretty much anywhere's after the START:·label and must have either +5v or ground and the RX pin connected to the serial LCD.
The Time and Date does not get updated correctly if·the SEROUT command·is located before the START: label.
I haven't got a clue on this one. Although I think it could be·INTERRUPT related.
I have attached the program if anyone can help.
Thanks.
Comments
I briefly looked through the code. I am attempting to focus on the program flow and not on the parts that perform the I/O. I see the INTERRUPT, the interrupt handler, the SEROUT command, and the Main loop. This combination should perform your intended task. It sounds like the combination to perform it correctly still needs tweaking.
INTERRUPT
Is the syntax for this correct? I was reviewing the help and could not find a match for what is written but I've never used it myself.
Do you really want it to interrupt every millisecond? If so, the subroutines that communicate with the DS1302 may get interrupted. They are async but it's possible the interrupt is affecting the communication (I think there are minimum pulse width times to consider).
Have you been able to set the program up to run without the interrupt? I'm not suggesting that you remove it entirely. I'm suggesting to remove it just to isolate it as a possible cause. How does the program run without it?
COMMENTED OUT CODE
I noticed that the GetTimeAndData call is commented out. Is this done purposefully? Also, the IF statement surrounding the code inside the Main loop is commented out as well. Without that, the code runs everytime through the loop? Is this your intent?
STEPPING THROUGH
Is it possible to step through the code after the second attempt to display the data and time? This may yield some clues. If so, I would inspect the values of the data and time. If they are zero, then something may be affecting the communication with the DS1302 as I suggested above.
SEROUT
Does SEROUT get called with every interrupt? If so, the command may not have enough time to complete the task before the next interrupt.
When I have debugged through microcontroller code, I have had to comment out whole sections of code and add them back one at a time to help isolate the main issue. As you suggested, it seems odd that a SEROUT and LCD Display are required for an INTERRUPT. Indeed, if I understand what you are attempting, the LCD and the LED Matrix should be able to operate independently of one another.
Joe
·Even if I commented out the SEROUT command AND / OR removed the LCD from the circuit....the TimeDate ( ) variable never updates correctly unless the SEROUT command is inserted (not commented out) AND the LCD is plugged in to the circuit.
Back to the drawing board. I will keep trying with DEBUG next for TimeDate(Hrs), (Mins) and (Secs). ....
Post Edited (T&E Engineer) : 4/8/2007 1:56:12 AM GMT
Here is the working display (unfortunately with an LCD attached):
http://www.youtube.com/watch?v=HtUVlkJdNwM
PS: I also added a bit more code that scrolls up a 16x16 picture in a WDATA statement.
Post Edited (T&E Engineer) : 4/8/2007 12:08:33 PM GMT
Just thought I would through some more wood into the fire. Don't forget to see·my·YouTube.com video I made of·what it looks like·working WITH a serial LCD connected. I will make another video showing what it looks like when·the Serial LCD·is not connected·to an RA line with the wrong display updates on the Time.
Thanks for sticking with me.
I cannot help but think that·this is attributable to·some wiring error/s (you've possibly lost a ground in there with a bum breadboard contact or somesuch.)
I'm not sure what you are saying by my comment. All I mean is that the program's TimeDate() variable will not update properly unless a serial LCD is connected to one of the unused RA lines. The serial LCD can be fully powered (weird characters are present because it has not been configured in the program - also the interrupt may be the cause of that) OR the serial LCD needs to have either (+5v and the RX) OR·(Ground and the RX). However, I will rebuild this simple DS1302 circuit on another solderless breadboard to see if that matters.
BTW: I made another YouTube.com video showing how disconnecting the (ground and RX only) serial LCD causes the updated time to clear out to 00:00:01 AM··· and··· not the expected 12:00:05 AM (or higher clocked response).
http://www.youtube.com/watch?v=Uj3GMY8hTp8
·I have also attached the latest code for review.
Post Edited (T&E Engineer) : 4/8/2007 4:42:41 PM GMT
Picture 1 shows a different solderless breadboard with the following connections:
1. Power is being taken from Vdd and Vss (black and white wire from the SX52 to the solderless breadboard).
2. 3 orange wires go from RA.0 - RA.2 into the DS1302 pins 7,6 and 5 respectively.
3. 1 yellow wire goes from RA.3 (however any unused RA pin would have the same bad effect - RA.3 - RA.7) to the white Serial LCD RX pin.
4. A black ground wire is going to the black Serial LCD ground pin.
5. +5v (red wire) is going·to the DS1302 (pin 1).
6. Ground (black wire) is going to the DS1302 (pin 4).
Picture 2
Shows the Time Display is correct (12:00:xx AM)·AND the Serial cable IS plugged in to the LCD.
Picture 3
Shows the Time Display is not correct (00:00:xx AM) AND the Serial cable IS NOT plugged into the LCD.
I hope this makes it more clear. I am at a loss for figuring this strange occurance out.
Post Edited (T&E Engineer) : 4/8/2007 5:11:48 PM GMT
· ·+V·& RX·······= OK
··GND·& RX······ = OK
·(+V·&·GND) & RX = OK
·
· I may be totally out of it, but this just leads me to figure that you're getting, at least, a·Ground from the LCD.· If nothing is using the LCD and especially since it provides no feedback (as it never TX's back to the SX or anything else) -- what else could it be?
· Is there a complete schematic (is it in one of the other Subjects that you've originated)?
·
I decided to take the plunge and solder the socketed DS1302 directly to the SX52 protoboard.
All is working now with no serial LCD attached and no TRIS_A or SEROUT command needed. This one blew me away. Was it perhaps a problem of using long wires going to a solderless breadboard (actually tested it on 2 different breadboards). Certainly this appears to be a transmission line issue now that all the wires are short and on one PCB.
Many thanks to all including Bean, Sparks-R-Fun, PJ Allen and especially JonnyMac and JDOhio.
Now I have 5 I/O lines available (RA.3 - RA.7 - God· I love the SX52 !!) - Perhaps some switches or something - Phase II.
Thanks again to all !!!
I will start making some complete schematics and post this project in the "Completed Projects" section.
Post Edited (T&E Engineer) : 4/8/2007 6:05:35 PM GMT