Learning how to use USART


Results 1 to 14 of 14

Threaded View

  1. #1

    Default Learning how to use USART

    I'm trying to get one PIC to talk to the other. I'm not using MIDI messages at this point, but I am using MIDI hardware to connect the two PICs. The schematics are found here https://www.tigoe.com/pcomp/code/picbasic-pro/161/

    I'm using two 16F887. One is the transmitting PIC. MIDI out hardware is connected to pin 25/portc.6/TX. I'm trying to send the numbers 1 ~ 9 every 600ms. An LED blinks each time it's supposed to send just to let me know that it's doing something.

    The other PIC is supposed to receive the number and display it on an LCD. The MIDI in hardware is connected to pin 26/portC.7/RC. I made the LCD display "ready to receive" at start up so I know that it's working.

    The blinking LED on the transmitting PIC is working, and the LCD on the receiving PIC is working, but I'm not seeing any numbers being displayed.

    Here's the code for the transmitting PIC:
    Code:
    define OSC 20
    define HSER_RCSTA 90h
    define HSER_TXSTA 20h
    define HSER_BAUD 31250
    
    
    ANSEL = %00000000
    ANSELH = %00000000
    TRISD = %00000000
    TRISE = %00000000
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %01000000
    
    
    send var byte
    
    
    main:
    
    
    send = send + 1
    hserout [send]
    PORTA.0 = 1
    pause 300
    PORTA.0 = 0
    pause 300
    if send >= 10 then
        send = 0
    endif
    
    
    goto main
    Here's the code for the receiving PIC:
    Code:
    CLEARdefine LOADER_USED 1
    define OSC 20
    define HSER_RCSTA 90h
    define HSER_TXSTA 20h
    define HSER_BAUD 31250
    define LCD_DREG PORTD
    define LCD_DBIT 0
    define LCD_RSREG PORTE
    define LCD_RSBIT 0
    define LCD_EREG PORTE
    define LCD_EBIT 1
    define LCD_RWREG PORTE
    define LCD_RWBIT 2
    define LCD_BITS 4
    define LCD_LINES 4
    define LCD_COMMANDUS 2000
    define LCD_DATAUS 50
    
    
    ANSEL = %00000000
    ANSELH =%00000000
    TRISD = %00000000
    TRISE = %00000000
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %01000000
    
    
    data_in var byte
    
    
    pause 250
    lcdout $fe, 1
    lcdout $fe, $d4, "ready to receive"
    pause 500
    lcdout $fe, 1
    pause 250
    
    
    main:
    
    
    hserin [dec data_in]
    pause 5
    if data_in != 0 then
    gosub display
    endif
    goto main
    
    
    display:
    lcdout $fe, 1
    lcdout $fe, $94, dec data_in
    data_in = 0
    return
    Last edited by keithv; - 9th May 2018 at 21:26.

Similar Threads

  1. remote code learning
    By Bruce in forum Code Examples
    Replies: 20
    Last Post: - 21st February 2021, 16:38
  2. Replies: 7
    Last Post: - 12th January 2018, 18:02
  3. USB Learning
    By ruijc in forum USB
    Replies: 19
    Last Post: - 26th July 2014, 22:09
  4. Learning Basic
    By bartman in forum General
    Replies: 14
    Last Post: - 19th November 2004, 01:45

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