Serin2 pass through to Serout2


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2005
    Posts
    37

    Default Serin2 pass through to Serout2

    I am trying to get the following code to work but get garbage on the other side.

    Code:
    serin2 GPIO.1,84,5000,mainloop,[str command\4\13]  ' This could be Acr, E'dc1'cr or E'dc3'cr
    
    If (command[1] == 19) then ' 19 = DEC for 'dc3' char
        goto IButton
    else
        SEROUT2 GPIO.4,84,[str command,13]    ' Cannot get the same on the output
        serin2 GPIO.5,84,5000,mainloop,[str command\31\13]  '  Then get response
        SEROUT2 GPIO.0,84,[str command,13   ' Then send back to PC
    endif
    Any ideas? Should I wait a few ms between sending back out the other port? Should I be using something other than STR to send back to the pc?

    Thanks in advance,

    Scott

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Please, when you post a question, give us all details such as PIC #, Using internal OSC or not, String format or Bin or Dec format. Same thing on PC side, which software, setting etc etc.

    First thing to try, send a text string to the PC, if everything is correct, send a text string + 1 byte of data from your PC to the PIC and use WAIT modifier + 1 variable. if the content of the variable match everything should be correct... at very least the hardware.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Mar 2005
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Here are the details:

    PIC12F675
    Internal OSC 4 mhz

    It only gets garbage when I enable the second 232 port on GPIO.4! When I reroute the data how should it be formatted? Everything from the PC is ASCII format.

    Thanks,

    Scott

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I may think of few things here
    1) 9600 baud with internal osc is a bit dangerous, try at lower baudrate
    2) internal OSC calibration is screwed up.
    3) all multiplexed analog stuff are not disabled
    4) there's no max-232 (or else inverter) between the PIC and the PC
    5) noisy supply line
    6) maybe something else

    i'm doing a little something here, i'll post it later so you could try on your side as well
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    try this
    Code:
        
            '
            '       PIC Configuration
            '       =================
            @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
                    ' Internal Oscillator
                    ' Enable watch dog timer
                    ' Enable power up timer
                    ' Disable MCLR pin
                    ' Enable brown out detect
        
            DEFINE OSCCAL_1K 1      ' load internal osc calibration
            
            '
            '       Hardware configuration
            '       ======================
            TRISIO = %00101010      ' set GP3, GP4, GP5 input
                                    ' others to output
            ANSEL = 0               ' disable adc
            CMCON = 7               ' disable comparators
            
            '                      
            '       Hardware assignment
            '       ===================
            S_In1   var GPIO.1      ' Serial input #1   
            S_In2   VAR GPIO.5      ' Serial input #2
            S_Out   VAR GPIO.4      ' Serial output
        
        
            '   
            '       Variables definition 
            '       ===================
            Command VAR BYTE[10]
            Baud    var word
            
            '
            '       Constants definition 
            '       ====================
            T2400   CON 396
            T4800   CON 188
            T9600   CON 84
            N2400   CON 16780
            N4800   CON 16572
            N9600   CON 16468   
        
            '
            '       Software/Hardware initialisation
            '       ================================
                    '
                    '       select baudrate
                    '       ---------------
            baud = t9600
                    '
                    '       Set serial output pin idle level
                    '       --------------------------------
            if baud<400 then
                high s_out
                else
                    low s_out
                endif
        
            pause 50            ' settle time    
            serout2 s_out,baud,["Hello, this is a test!!!",13,10]
                    
            '
            '       Program Start
            '       ============
    Start:
            serout2 s_out,baud,["i'm waiting for incoming data on GPIO.1",13,10]
            serin2  s_in1,baud,[str command\10\13]
            
            Serout2 s_out,baud,["i got...", str command,13,10,13,10,_
                                "waiting for some data on GPIO.5",13,10]
                                
            serin2  s_in1,baud,[str command\10\13]
            Serout2 s_out,baud,["i got...", str command,13,10,13,10]                                
            goto    start
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Mar 2005
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Steve,

    Thanks for your time! I will try this when I get home this evening.

    4) there's no max-232 (or else inverter) between the PIC and the PC
    Sorry forgot to mention the PIC connects to a Bluetooth radio then to the PC. This has been a stable product of ours for the last 1 1/2 years. This is a test for our customer adding the IButton. Both sides are direct connect!

    Thanks,

    Scott

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Serout and 18F87J50
    By Glenn_Webber in forum Serial
    Replies: 8
    Last Post: - 20th November 2009, 14:26
  3. SLOW Serin2 and Serout2
    By dragons_fire in forum General
    Replies: 3
    Last Post: - 26th June 2009, 02:38
  4. SEROUT2 and SERIN2 commands
    By bangunprayogi in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th August 2005, 09:03
  5. Simple PC Menu System with Serin2
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd April 2005, 08:27

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