Communication between two PicChip


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    I was heading in that direction using HSEROUT, starting reading the pic datasheet communication section and that led me to ask that question. I'll be working on HSEROUT tonight. I think it is a better practice then using serout in a free style way.

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    working on it
    Last edited by lerameur; - 15th November 2011 at 01:05.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    STILL NOT TRANSMITTING. as least I am getting any compilation errors..: here is my transmitter code:

    (I just see these before word on my LCD)

    Code:
    INCLUDE "modedefs.bas"
     OSCCON = 110000 '8 Mhz
     Define OSC 8 
     
        ' Set transmit register to transmitter enabled
        DEFINE HSER_TXSTA    20h
    
        ' Set baud rate
        DEFINE HSER_BAUD    2400
    
        ' Set SPBRG directly (normally set by HSER_BAUD)
        DEFINE HSER_SPBRG    25
        
    CMCON = 7 : ANSEL = 0 : ADCON1 = 7
    '/////////////////////////
    '// LCD configuration //
    '/////////////////////////
    
    DEFINE LCD_DREG PORTA ' Set LCD Data port
    DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 0 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 6 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 500
    
    cou var byte
    temp1 var byte
    temp2 var byte
    
    Mainloop:
    
      temp1 =18: temp2 =22
      cou =44 
    
    
    lcdout $FE,1, "TempC: ", dec (temp1) , ".", dec2 temp2," ",$DF,"C"
    lcdout $FE,$C0, bin cou , ".","F"
    pause 400
    
    Hserout [DEC temp1]
    PAUSE 50
    
    lcdout $FE,1 : LCDOUT "second  ", dec (temp2 / 100) , ".", dec2 temp1," ",$DF,"r"
    lcdout $FE,$C0, dec cou , ".","23"
    pause 400
    
    goto mainloop
    
    end
    and my receiver code
    Code:
    INCLUDE "modedefs.bas"
     OSCCON = 110000 '8 Mhz
     Define OSC 8 
     
         ' Set receive register to receiver enabled
        DEFINE HSER_RCSTA    90h
    
        ' Set baud rate
        DEFINE HSER_BAUD    2400
    
        ' Set SPBRG directly (normally set by HSER_BAUD)
        DEFINE HSER_SPBRG    25
        
        
    CMCON = 7 : ANSEL = 0 : ADCON1 = 7
    '/////////////////////////
    '// LCD configuration //
    '/////////////////////////
    
    DEFINE LCD_DREG PORTA ' Set LCD Data port
    DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 0 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 6 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 500
    
     encoded22 var word 
    
    
    Mainloop:
    
    
    lcdout $FE,1 , "hello  "
    lcdout $FE,$C0, "before"
    pause 300
    
    Hserin [DEC encoded22]
    PAUSE 100
    
    lcdout $FE,1, "after"    
    lcdout $FE,$C0, "AFTER: ", "-", dec encoded22 , "After"
    Pause 300
    
    
    goto Mainloop
    
    end
    Last edited by lerameur; - 15th November 2011 at 02:43.

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


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    How are the two chips connected?

    chip#1 ground to chip#2 ground
    chip#1 TX to chip #2 RX
    ???
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    YES THE CHIPs has a common ground. RB5 is going to the receiving pic on RB2 (PIC16F88)

    ken

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


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    Try these settings on both the Tx and RX chip
    Code:
    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
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: Communication between two PicChip

    just copied and paste your code and still did not work. Same as before.....

    ken

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