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

    Smoke and mirrors???


    Here is a simple example to build on

    SEND:
    Code:
    SEROUT PORTC.4,T2400,[9,3]
    RECEIVE:
    Code:
    SERIN PORTC.4,T2400,[9],net
    
    IF net = 3 THEN DO_SOMETHING
    Connect VSS and the two PIC pins together.
    Dave
    Always wear safety glasses while programming.

  2. #2


    Did you find this post helpful? Yes | No

    Default ok....just another question ...

    Dave

    Will try the operation with only your code...
    Can one run SERIN and SEROUT on same pic as I would like to send the received data to hyperterminal and also to the LCD. So would the fol.lowing code be correct then ?
    Oh and why did you choose PORTC.4 ? Looking at the pinouts for both pics I see PORTC.6 is TX and PORTC.7 is RX -are these for hardware serial , ie. HSERIN and HSEROUT and should I use them for SERIN and SEROUT or is it better to use PORTC.4 in case I want to use them for HSERIN/OUT later ?

    Here's the code

    Transmitter PIC (16F887)
    Code:
    SEROUT PORTC.4,T2400,[9,3]
    Receiver PIC (18F4520)
    Code:
    main:
    
    SERIN PORTC.4,T2400,[9],net 'prepare to receive the data from other PIC
    IF net = 3 LCDOUT "data is",net 'look for the number 3
    SEROUT PORTC.5,T2400,[9,3] 'send received data to hyperterminal via max232n to PC
    end if 
    goto main 
    end
    Smoke and mirrors indeed :-)

    Kind regards

    Dennis
    Last edited by Dennis; - 26th November 2009 at 21:51.

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


    Did you find this post helpful? Yes | No

    Default

    I went with PORTC4 for no good reason other than to show that the bit banging routines work on most any pin. You are correct about HSERN only working on the hardware pins.

    What I can see of your code(using phone) it looks like it should work.
    Dave
    Always wear safety glasses while programming.

  4. #4


    Did you find this post helpful? Yes | No

    Default Thanks Dave

    Dave

    Thanks a million for the feedback

    Will try it right away and feedback asap :-)

    Kind regards

    Dennis

  5. #5


    Did you find this post helpful? Yes | No

    Default it works :-)

    Hi Dave

    Good news and a big thank you !!
    It's working...
    I am transmitting from 16F887 to 18F4520 and then from 18F4520 to and LCD and to PC serial port.

    One tiny issue I have is with the serin command.
    It displays a string fine but the variable is always a wingdings character unless I use a lookup ...(see my code below for serout on receiver)
    So I have three questions now ....
    1. Is there any way to set the serin command to send the variable (net) in the code example so that it appears as the number 3 ?
    2.Could you possibly show me a code snippet to accomplish the same thing using debug and also hser please
    3. Bearing in mind I want to eventually to accomplish all of this using RF modules, and may decide to use hserin/out ,and all I want to do is relaible transmit 3 or possible 4 bytes, would I have to use an external oscillator or would the internal suffice ?

    Kind regards
    Dennis

  6. #6
    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.

  7. #7
    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.

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