Serial communication fails after long pause


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2006
    Posts
    70

    Default Serial communication fails after long pause

    I'm having a strange problem which I suspect is due to hardware, but who knows. I'm trying to communicate with a palm pilot via RS232 through a MAX232 unit. I have SEROUT2 commands scattered throughout my code and they work until I reach a point in which there is a long (10 second) pause. A SEROUT2 command follows the pause and gives me an error on the palm. When I run the program hooked up to a serial communicator on a PC, I don't get an error, but the SEROUT that follows the pause is mostly garbeldygook. The SEROUT commands that follow are OK.

    I've monitored the voltage on the serout pin and it is zero during the pause. I've tried baud rates from 300 to 9600 (strangely 9600 works the best) and the problem remains. Any suggestions as to what is going on during the long pause? Do I need pull-ups or pull-downs on the serial pins?

    Here is the code--all simple stuff....

    Code:
    '****************************************************************
    '*  Name    : B_Logger.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 2/6/2008                                          *
    '*  Version : 1.0                                               *
    '*  Notes   : PIC16F688                                               *
    '*          : INTERNAL OSC; MCLR OFF                                                  *
    '****************************************************************
    
    'BIRDLOGGER CONTROL PROGRAM
        'I2C COMMUNICATION VIA PORTS C4 AND C3
        'ANALOG INPUT ON PORTA.0
        'DIGITAL INPUT ON PORTC.1 WITH 10K PULLUP
        'RS232 COMMUNICATION
            'PORTA.5 DATA IN
            'PORTA.4 DATA OUT
        'PORTA.1 output; start/stop
        'PORTA.2 output; maintain power
    
    'DEFINE VARIABLES
    B0 VAR BYTE
    B1 VAR BYTE
    
    'ALIAS PINS
    SDA     VAR PORTC.4
    SCL     VAR PORTC.3
    SDIN    VAR PORTA.5
    SDOUT   VAR PORTA.4
    REC     VAR PORTA.1
    PWR     VAR PORTA.2
    SWITCH  var PORTC.1
    FLEX    VAR PORTA.0
    
    'DEFINE PINS
    TRISA = %00100001
    TRISC = %00000010
    
    LOW REC
    SEROUT2 SDOUT,84,["test 9", 13, 10] 
    pAUSE 10
    
    MAINLOOP:
    SEROUT2 SDOUT,84,["MAIN LOOP", 13, 10]
    PAUSE 10
    IF SWITCH = 0 THEN trigger 'MONITOR THE SWITCH    
    PAUSE 10
    IF SWITCH = 0 THEN trigger
    B0 = B0 +1 'COUNTING VARIABLE TO CONTROL PWR BUTTON
    if B0 = 10000 THEN 'ONCE EVERY 2-3 MIN PRESS THE PWR BUTTON TO KEEP CAMERA ON
        B0 = 0 'RESET COUNTING VARIABLE
        HIGH pwr 'PRESS PWR BUTTON
        FOR B1 = 1 TO 20 'LOOP THAT ALLOWS PWR BUTTON TO STAY PUSHED FOR .2 SEC TO OVERCOME BOUNCE COCNTROL
        IF SWITCH = 0 THEN trigger 'MAINTAINS SWITCH MONITORING   
        PAUSE 10
    NEXT B1
    ENDIF
    GOTO MAINLOOP 'RETURN TO THE BEGINNING
    
    End
                               
    trigger:
        SEROUT2 SDOUT,84,["trigger", 13, 10]
        PAUSE 10
        HIGH REC 'HIT THE RECORD BUTTON TO ACTIVATE RECORDING
        Pause 250 'PAUSE TO OVERRIDE BOUNCE CONTROL
        LOW REC 'RELEASE RECORD BUTTON
        Pause 500 'RECORD FOR 1/2 SECOND
        HIGH REC 'HIT RECORD BUTTON AGAIN TO STOP RECORDING
        Pause 250
        LOW REC 'RELEASE RECORD BUTTON
        Pause 10000 'LONG PAUSE TO LET CAMERA STORE VIDEO
        SEROUT2 SDOUT,84,["recording done", 13, 10]
        Pause 10
        REPEAT 
            SEROUT2 SDOUT,84,["waiting...", 13, 10]
            pAUSE 100
        UNTIL SWITCH = 1
        SEROUT2 SDOUT,84,["back to loop", 13, 10]
        GOTO MAINLOOP

  2. #2
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    I have to revise what I said above. It is not the pause that causes serial communication to fail but the toggling of PORTA.2. When I comment out the HIGH REC and LOW REC stuff the serial comm works. I'm still in the dark as to what is going on tho. Why should toggling a pin on another port affect serial communication? I've also got problems getting the input on PORTC.1 to work. I've got a pull-up tied to the port and a switch connecting to ground. The pin reads high on my volt-meter but the program runs as though it is always low. Craziness abides.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by brid0030 View Post
    I have to revise what I said above. It is not the pause that causes serial communication to fail but the toggling of PORTA.2. When I comment out the HIGH REC and LOW REC stuff the serial comm works. I'm still in the dark as to what is going on tho. Why should toggling a pin on another port affect serial communication? I've also got problems getting the input on PORTC.1 to work. I've got a pull-up tied to the port and a switch connecting to ground. The pin reads high on my volt-meter but the program runs as though it is always low. Craziness abides.
    I don't see ANY ANSEL, ADCON0, ADCON1, CMCON0, CMCON1 register settings anywhere in there...
    Take a look at the datasheet and see if your fix is anywhere around there.

  4. #4
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Right, I just figured that out. I'll post the solution as it trickles in.

  5. #5
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    OK, so CMCON0 = 0 and ANSEL = 0 solved everything.

    See http://www.picbasic.co.uk/forum/arch...php/t-561.html.

    I'm such a rookie....

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  2. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  3. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  4. Fade out LEDs question
    By Sam in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd June 2008, 10:50
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 03:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts