Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT command and Serial LCD must be present in order for program with an INTE — Parallax Forums

SEROUT command and Serial LCD must be present in order for program with an INTE

T&E EngineerT&E Engineer Posts: 1,396
edited 2007-04-08 17:56 in General Discussion
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.

Comments

  • JDOhioJDOhio Posts: 72
    edited 2007-04-08 00:25
    T&E Engineer,

    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
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-04-08 01:33
    I just tried changing the DEVICE code for an internal 4MHz clock and even though I got the Warning message about using an internal clock with SEROUT....I still saw the same bad results. No fix here. I will keep trying.
    DEVICE   SX52, OSC4MHZ, BOR42 'Use the internal 4 MHZ
    FREQ            4_000_000
    ID              "16x16"
    

    ·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
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-04-08 02:17
    I did some DEBUGing and found that it is NOT related to the INTERRUPT. I can comment out the INTERRUPT calling and still the TimeDate() does not update properly unless the SEROUT command is after the Start: label AND the Serial LCD is plugged in to the circuit. Obviously when the INTERRUPT calling is commented out, then the LED matrix does not turn on - so I can see the variables in the DEBUG statements below. I tested it with and with out the conditions of the SEROUT and LCD plugged in. I'm not sure where to go next. Here is the DEBUG statement's I used:
    Start:
    
     ' PROBLEM HERE - MUST HAVE A SERIAL LCD CONNECTED FOR TIME / DATE TO UPDATE CORRECTLY. 
    
     
     ' SEROUT command can be located pretty much anywhere's after the START: label. 
     
     
    'SEROUT DISPLAYComPort, DisplayBaud, 0 
     
     
     
     
    ' Set up TimeDate array (this initializes the time/date to 11:59:50 PM 12/31/07 Mon)
    TimeDate(Secs) =  $50
    TimeDate(Mins) =  $59
    TimeDate(Hrs) =   $11 ' if modeFlag is set to Hr24, TimeDate(Hrs) = $00 to $23 otherwise $00 to $11 when Hr12 is set
    TimeDate(Date) =  $31
    TimeDate(Month) = $12
    TimeDate(Day) =   $01
    TimeDate(Year) =  $07
    TimeDate(Ctrl) =  $00
    ampmFlag = PM  ' if modeFlag is set to Hr12, ampmFlag is AM or PM
    modeFlag = Hr12  ' set to either modeFlag = Hr12 or Hr24
     
    For Idx = 0 to MESSAGESIZE
     Message1(Idx) = " "
     Message2(Idx) = " "
    NEXT
     
    tmpB1(2) = 0 ' Scroll Direction
    SetMode
    SetTimeAndDate
    'tmpB1(3)=0
    
      
    Main:
    
    DO
       'GetTimeAndDate
     'IF TimeDate(Secs) <> tmpB1(3) THEN
      
      WriteTimeToLED
      WriteDateToLED
     
    J = TimeDate(Hrs)
    \ WATCH J, 8, uhex
     
    K = TimeDate(Mins)
    \ WATCH K, 8, uhex
     
    X = TimeDate(Secs)
    \ WATCH X, 8, uhex
     
    BREAK
    
      
      'tmpB1(0) = 0
      'tmpB1(1) = 2
     
      
      tmpB1(0) = 0
      StringWriter
      tmpB1(0) = 1
      StringWriter
    
        'ENDIF
       'tmpB1(3)=TimeDate(Secs)
    LOOP
    
    END
    

    ' -------------------------------------------------------------------------
      
      'INTERRUPT 1000    ' run every millisecond
      
    ' -------------------------------------------------------------------------
      'GOTO INT_HANDLER 
      
    
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-04-08 11:59
    Here is a YouTube.com video I made showing how it works correctly IF the LCD is connected. In this case I have a yellow wire coming off of an RA line to the RX connector on the Serial LCD. You will also see that the LCD is off because it only has the RA line and Ground (black wire) going to the serial LCD. I will shoot another video later that shows what it looks like if there is no LCD attached.

    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
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-04-08 15:42
    I found another strange factor. If add a TRIS_A xxxxxxxx (any combination of 0's or 1's - Ive tried most all of them) after the Start: label· then I can comment out the SEROUT command. Unfortunately you still need to have either the Serial LCD +5v or GND or both AND the RX connected·to·ANY of the unused RA lines being RA.3 or·4 or 5 or 6 or 7. As·long as I have it connected to one of them, then the·TimeDate(Hrs)·... (Mins) ... (Secs) updates·properly from·· 11:59:50·PM·· to··· 12:00:05 AM. If the Serial LCD is not connected·to one of the RA lines (either with a TRIS_A command or a SEROUT command listed after the Start: label) then it will not update properly going from 11:59:50 PM··· to·· 00:00:01 .·(???)

    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.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-04-08 16:11
    T&E, you stated: "Unfortunately·I still need to have either the Serial LCD +5v or GND or both AND the RX connected·to·ANY of the unused RA lines".

    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.)
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-04-08 16:34
    PJ Allen,

    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
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-04-08 17:03
    I took 3 pictures.

    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
    640 x 480 - 134K
    640 x 480 - 155K
    640 x 480 - 150K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-04-08 17:51
    · I believe that I do get it: you're saying that·you must (however inexplicably)have·your serial-LCD, which is not being used by this project (anymore),·with its +V and/or GND and, additionally, its RX line connected to your SX-board·for operation.
    · ·+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)?



    ·
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2007-04-08 17:56
    PROBLEM IS SOLVED !!!!! - ALTHOUGH I'm NOT SURE WHY.

    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
    640 x 480 - 148K
    640 x 480 - 149K
Sign In or Register to comment.