PIC to PIC interupt serial character problems


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Location
    San Diego, CA
    Posts
    8

    Default PIC to PIC interupt serial character problems

    I started this project a couple of years ago and I was stuck when I put it to the side. I recently brought it back to life and I am still stuck!

    Here is the deal: 16F628 w/20mHz OSC sends a "1 2 3 4" with a second between each character cycling over and over while bllinking an LED. The 628 sends the data to a 16F876 w/20mHz OSC on PortC.7 through an interrupt while going through an endless loop.

    The problem: The 628 sends the varible "I" which equals (ASCII 1, ASCII 2, ASCII 3, or ASCII 4), but the 876 spits out 103 for the ASCII 1, a 51 for the ASCII 2, a 102 for the ASCII 3, and 25 for a ASCII 4. My Question is why?

    Code for the 16F628
    Code:
    @ DEVICE HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    
    define OSC 20
    
    CMCON = %00000111   ' Page 56, Comparators Off
    
    CHAROUT VAR PORTB.3
    LED         VAR PORTB.7
    BAUD       CON 6
    I              VAR BYTE
    
    
    PAUSE 2000
       
    start:
        for I = 1 to 4
            HIGH LED
            PAUSE 500
            LOW LED
            PAUSE 500
            SEROUT2 CHAROUT,16468,[#I]    ' N9600
        NEXT
    GOTO START
    and the code for the 16F876
    Code:
    @ DEVICE HS_OSC,LVP_OFF,WDT_OFF,PROTECT_OFF
    
    define OSC 20
    
    INTCON = %01000000  ' Page 22, PEIE=1  
    PIE1 = %00100000      ' Page 23, RCIE=1    
    TXSTA = %00100100   ' Page 97, TXEN=1, BRGH=1
    RCSTA = %10010000   ' Page 98 , SPEN=1, CREN=1
    SPBRG=129                ' Page 100, 9600 BAUD (BRGH = 1)
    
    TRISC = %10000000    ' PortC.7 Input
    
    RCIF    VAR PIR1.5        ' Page 24, USART Receive Interrupt Flag bit
    
    
    CHAR    VAR BYTE     
    X         VAR BYTE    
    FLAG    VAR BYTE
    
    BAUD    CON 6       ' 9600 Driven Inverted
    LCD      VAR PORTC.4
    
    
    on interrupt goto ROUTINE
    
    PAUSE 1000        ' Wait for LCD 
    SEROUT LCD,BAUD,[12,"Working. . ."]  '12=Clear screen and verify working
    PAUSE 1000
    SEROUT LCD,BAUD,[12]                     '12=Clear screen
    
    loop:
          
    GOTO loop
    
    
    disable INTERRUPT
    ROUTINE:
        RCSTA=%00000000 ' Page 98, Serial port disabled, Disable continuous receive
        CHAR = RCREG        ' Get character
    
        while RCIF               ' Empty RCIF 
        X = RCREG       
        wend            
    
        SEROUT LCD,BAUD,[12,#CHAR]  ' Clear Sceen and display ascii value
    
        RCSTA=%10010000    ' Page 98 , SPEN=1, CREN=1
    resume              
    enable INTERRUPT

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    The sending PIC should be using true mode instead of inverted to communicate with the
    USART on the receiving end.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    May 2005
    Location
    San Diego, CA
    Posts
    8

    Thumbs up

    Thanks Bruce!! That did the trick.

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. serial to PIC
    By kindows in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 14th July 2009, 13:58
  3. Midi, Interrupts and Pic better than SX28?
    By Lajko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2008, 00:26
  4. PIC to PIC Serial Communication
    By v_merino in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd July 2004, 07:05
  5. serial comm from Pic to STAMP
    By d1camero in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th April 2004, 23:58

Members who have read this thread : 0

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