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

    For the 887 use 8Mhz for the calcs.

    I am not sure about the 4520, I have not used USART with PLL enabled.
    But...
    I think the USART uses the primary OSC so try 4Mhz. 50 50 chance of it working
    Dave
    Always wear safety glasses while programming.

  2. #2


    Did you find this post helpful? Yes | No

    Default osciallator..

    Hi Dave

    Could I set both PICS to 4 MHz internal OSC ?
    And once it's working try variations ?

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


    Did you find this post helpful? Yes | No

    Default

    That would be the way to trouble shoot.
    Just make sure they are running at the expected speed with a blinky and a stop watch or meter if you have one..
    Dave
    Always wear safety glasses while programming.

  4. #4


    Did you find this post helpful? Yes | No

    Default ok...and now for the RF plunge :-)

    Hi again Dave

    I think I am almost ready for the next step ....
    RF and RF module TX RX
    I have been reading posts all through the forums, even some of yours from years back ...
    Now for the next step ... to try the same or a similar thing without the wires.

    Should I start off with sering or plunge straight into HSER ?

    The plan is to be able to send 3 bytes using the most reliable method.

    So the question is where do I start and what do I start with ?

    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

    So do I choose 4MHz or 32 MHz ?
    I have it on good authority that the PLL speed is the one to use. Thanks Bruce!!!

    What radio modules are you using? I have only used the ones from rentron.com.

    As for reliability, all of the serial methods (HSER,SER,SER2..) are good. Are you planning to use interrupts with the serial input or just wait and time out, check later sort of thing?
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default ok here goes

    Hi Dave

    :-)

    So are you saying I should use 8MHz OSC and 4x PLL for the 18F4520 and use 32 MHz when I do the HSER DEFINE calculations then ?
    And on the 16F887 use it's max INTOSC which is 8 MHZ for the HSER calculations ?
    OR....
    set both PIC's at 4 or 8 MHz and then calculate the HSER DEFINEs accordingly ?

    Something like this maybe
    Code:
    ‘For 8MHz @ 2400bps
    
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 51  ' 2400 Baud @ 8MHz, 0.17%
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 51  ' 2400 Baud @ 8MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    ‘For 4 MHz @ 2400bps
    
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 25  ' 2400 Baud @ 4MHz, 0.17%
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25  ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    A quick question here ...
    Which comes first ... DEFINE's or register settings ?

    Chat soon

    Dennis

  7. #7


    Did you find this post helpful? Yes | No

    Default looping HSER

    Hi Dave

    Have been reading the very interesting HSER info form all over.

    Let's say that I have the PIC's connected as follows :
    PIC 16F887 -- PIC 18F4520 -- PC(com port)

    At PIC 16F887 the code is
    Code:
    'USART defines and register settings begin here     - use for HSERIN/OUT
        RCSTA = $90 ' Enable serial port & continuous receive
        TXSTA = $20 ' Enable transmit, BRGH = 0
        SPBRG = 51  ' 2400 Baud @ 8MHz, 0.17%
    
        DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
        DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
        DEFINE HSER_SPBRG 51  ' 2400 Baud @ 8MHz, 0.17%
        DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    '   Check port settings PORTC.6 = TX and PORTC.7 = RX
    '   For PIC to PIC TX to RX C.6 to C.7 and visa versa
    '   Don't forget TRISC=%10000000
    'USART defines and register settings end here
    
    main: 'tx loop begins
    high LED '  LED on
            Pause 1000       ' Delay for 1 seconds
    HSERout "9",DEC 3,$d,$a 
    low LED ' LED off
    pause 1000
    goto main
    On the 18F4520 (middleman RX and TX PIC in my setup)
    Code:
    'USART defines and register settings begin here     - use for HSERIN/OUT
        RCSTA = $90 ' Enable serial port & continuous receive
        TXSTA = $20 ' Enable transmit, BRGH = 0
        SPBRG = 51  ' 2400 Baud @ 8MHz, 0.17%
    
        DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
        DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
        DEFINE HSER_SPBRG 51  ' 2400 Baud @ 8MHz, 0.17%
        DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    '   Check port settings PORTC.6 = TX and PORTC.7 = RX
    '   For PIC to PIC TX to RX C.6 to C.7 and visa versa
    '   Don't forget TRISC=%10000000
    'USART defines and register settings end here
    
    main: 'tx and rx loop begins here
    high LED 'LED on 
    Pause 1000 ' delay for 1 second
    'HSER lines begine here
             HSERIN [WAIT("9"),DEC NET] '<< this is the format for the receiver or if you're looping
    LCDOUT $fe,1 
    LCDOUT "I received the number .." DEC NET
    HSERout "I received the number",DEC NET,$d,$a  'data to COM port on pc
    'HSER lines end here
    goto main 
    end
    And on the PC hyperterminal or MCS serial tool is waiting to receive and/or send back to PIC

    Have I got it right ?

    Kind regards

    Dennis

Similar Threads

  1. Direct PIC to PC without MAX232
    By acjacques in forum Serial
    Replies: 14
    Last Post: - 23rd October 2014, 22:32
  2. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 01: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, 09: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, 15:46
  5. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 01: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