PIC to PIC TX RX and PIC to PC COM RX ..a little help please


Closed Thread
Results 1 to 40 of 68

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try
    DEC net

    OSCs..... Some will not agree but many times times the internal is not stable enough at higher baud rates to be reliable.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    To set DEBUG up
    Code:
        DEFINE DEBUG_MODE  0    ' Debug sending TRUE serial data
        DEFINE DEBUG_REG PORTC  ' Debug Port = PortC
        DEFINE DEBUG_BIT 4      ' Debug.bit = PortC.4
        DEFINE DEBUG_BAUD 2400  ' Default baud rate = 2400
    Send
    Code:
    DEBUG 9,3
    Receive
    Code:
    DEBUGIN [WAIT("9"),DEC net]
    The same syntax works for HSERIN/OUT
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Thumbs up the long 'WAIT' .....

    Hi Dave :-)

    How are you ?

    Tried the code exactly as you suggested ...

    On the receiver end it seems like debug is just WAITing forever to receive the number 9 match but it never seems to get it, so that's where the program stops.
    I thought it might be the order of the numbers so I changed their order but that didn't fix the problem.

    Is it possible that the problem could be on the receiver PIC as I still have a serout line to send the data to the PC serial port to view in hyperterminal.
    Is it ok to run debug and serin in the same PIC ( wondering if this is a silly question) or should I use debug to transmit to hyperterminal as well ?

    Could the problem be that I have the DEFINE statements in the wrong place ? I noticed an extra space character in the code snippet you posted between mode and 0 .. removed that and recompiled but still no joy :-(

    Any suggestions ?

    Here's the code :
    Receiver
    Code:
    'debug defines begin here - necessary for degug operation
        DEFINE DEBUG_MODE 0    ' Debug sending TRUE serial data
        DEFINE DEBUG_REG PORTC  ' Debug Port = PortC
        DEFINE DEBUG_BIT 4      ' Debug.bit = PortC.4
        DEFINE DEBUG_BAUD 2400  ' Default baud rate = 2400
        'debug defines end here
        
    'Main code begins here       
    
            Pause 2000       ' Wait for LCD to startup
            
    test:                                                         
            lcdout $fe,1 
                    lcdout "starting tx rx"
         '*******************************************           
        '*SERIN PORTC.4,T2400,[9],net 'prepare to receive the data from other PIC
        '*this lines works perfectly to send data
         '*******************************************
         '
         '****heres the same thing using debugin (RX)- check/adjust defines for settings
         DEBUGIN [WAIT("9"),DEC net]
         '****end of debug line
        lcdout "rx complete"
        pause 1000
        lcdout $fe,1 'clear lcd screen
    IF net = 3 then 
        lcdout $fe,1 
        LCDOUT "data is ",dec net 'look for the number 3 
        pause 2000
    endif  
        lcdout $fe,1
        lcdout "begin serout to hyperterminal"
        pause 1000
        LOOKUP  net,[0,"123A456B789C*0#D"],net 'use lookup table to diplay proper display in hyperterminal
    ' send net variable to hyperterminal using serout 
        serout PORTC.3,T2400,["the key pressed or received value is ",net,10,13] 
        lcdout $fe,1
        goto test
    end
    Transmitter
    Code:
    'debug defines begin here
        DEFINE DEBUG_MODE 0    ' Debug sending TRUE serial data
        DEFINE DEBUG_REG PORTC  ' Debug Port = PortC
        DEFINE DEBUG_BIT 4      ' Debug.bit = PortC.4
        DEFINE DEBUG_BAUD 2400  ' Default baud rate = 2400
        'end of debug defines
    
    LED var PORTd.0   ' Alias PORTD.0 to LED
    
    
        
    loopy:
    high LED '  LED on
            Pause 1000       ' Delay for .5 seconds
    	low led 'LED off
             Pause 1000       ' Delay for .5 seconds
             '*this serout lines works perfectly :-)
             'SEROUT PORTC.4,T2400,[9,3]
                       '**another example - SerOut PORTC.6,T2400,["are you receiving this tx from 16f887 ",datatx]
            'DEBUG line starts here
            DEBUG 3,9
            'end of debug line
            
            pause 1000
               Goto loopy  ' Go back to loop and blink LED forever
            End
    'End of all code

  4. #4


    Did you find this post helpful? Yes | No

    Default a change in the code ...

    Hi again Dave

    Thanks for your help so far , I really am learning a lot :-)

    To double check that nothing on the circuit had changed I loaed the code for the serin and serout examples from earlier and all still works , which tells me the problem has something to do with the debug code.

    Reading through the help and forums and manual I noticed that DEBUGIN requires it's own set of defines .
    I'm still checking to see if the baud rate must be defines eg. debugin_baud ..which I tried anyway and the compiler didn't complain.
    So I tried it the code again with the updated degug statements but still no joy :-(

    Here's the updated receiver code:
    Receiver
    Code:
     'debugin defines
        DEFINE DEBUGIN_REG PORTC      ' Set Debugin port
        DEFINE DEBUGIN_BIT 4          ' Set Debugin pin bit
        DEFINE DEBUGIN_MODE 0         ' Set Debugin mode: 0 = true, 1 = inverted
        Define DEBUGIN_BAUD 2400      'set Debugin baud rate
        'Debugin defines end here
    'debugin commands end here
    
    'debug defines begin here - necessary for degug operation
     '   DEFINE DEBUG_MODE 0    ' Debug sending TRUE serial data
     '   DEFINE DEBUG_REG PORTC  ' Debug Port = PortC
     '   DEFINE DEBUG_BIT 4      ' Debug.bit = PortC.4
     '   DEFINE DEBUG_BAUD 2400  ' Default baud rate = 2400
        'debug defines end here
        
    'Main code begins here       
    
            Pause 2000       ' Wait for LCD to startup
            
    test:                                                         
            lcdout $fe,1 
                    lcdout "starting tx rx"
         '*******************************************           
        '*SERIN PORTC.4,T2400,[9],net 'prepare to receive the data from other PIC
        '*this lines works perfectly to send data
         '*******************************************
         '
         '****heres the same thing using debugin (RX)- check/adjust defines for settings
         DEBUGIN [WAIT("9"),DEC net]
         '****end of debug line
        lcdout "rx complete"
        pause 1000
        lcdout $fe,1 'clear lcd screen
    IF net = 3 then 
        lcdout $fe,1 
        LCDOUT "data is ",dec net 'look for the number 3 
        pause 2000
    endif  
        lcdout $fe,1
        lcdout "begin serout to hyperterminal"
        pause 1000
        LOOKUP  net,[0,"123A456B789C*0#D"],net 'use lookup table to diplay proper display in hyperterminal
    
        serout PORTC.3,T2400,["the key pressed or received value is ",net,10,13]
        lcdout $fe,1
        lcdout datatx
        pause 1000
        goto test
    end
    Kind regards

    Dennis

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try
    DEBUG "9",DEC 3
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default nope :-(

    tried it ...still no joy

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Dave ...

    Do I need the defines on the receiver for debugin ???

Similar Threads

  1. Direct PIC to PC without MAX232
    By acjacques in forum Serial
    Replies: 14
    Last Post: - 23rd October 2014, 21:32
  2. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 00:52
  3. PIC or xbee times out after Tx 504 bytes
    By archendekta in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd November 2009, 08:45
  4. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  5. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13

Members who have read this thread : 2

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