Serial Communication with PIC16F877A


Results 1 to 17 of 17

Threaded View

  1. #1
    Join Date
    Dec 2008
    Location
    Charlottesville, VA
    Posts
    31

    Question Serial Communication with PIC16F877A

    Hello again to all... I am testing pieces of code that I have put together from various sources. I am trying to get a communications link set up between my PIC16F877A and my PC. I am using the serial communicator that comes with MicroCode Studio Plus. If I understand what I'm trying to do correctly, the PIC should wait for a message from the PC. If it doesn't receive this message, it will timeout and is supposed to display "nada". However, when I don't send anything to the PIC, it returns 4 wierd looking symbols. Also, if I try to transmit something to PIC, it doesn't return anything at all. Any helpful advice would be greatly appreciated.

    Code:
    DEFINE OSC 20
    
    INCLUDE "MODEDEFS.BAS"
    DEFINE HSER_BAUD 9600   ' HSER baud rate
    DEFINE HSER_SPBRG 129   ' HSER SPBRG init
    DEFINE HSER_RCSTA 90h   ' HSER receive status init
    DEFINE HSER_TXSTA 24h   ' HSER transmit status init high speed
    'DEFINE HSER_EVEN 1      ' Use only if even parity is desired
    'DEFINE HSER_ODD 1       ' Use only if odd parity is desired
    DEFINE HSER_BITS 9      ' Use for 8 bits ''+ parity
    DEFINE HSER_CLROERR 1   ' Automatically clear HSERIN overflow errors
    
    TRISC=%10000000
    
    TimeDate VAR BYTE[6]
    
    Main:
        HSERIN 5000,TimeOut,[WAIT("A"),STR TimeDate\6]  ' A369621
        HSEROUT ["Rcvd string: ", STR TimeDate\6,13,10]    
        GOTO Main
                
    TimeOut:
        HSEROUT ["Nada",13,10]
        GOTO Main
    Port Settings:
    COM1
    9600 Baud
    No Parity
    Byte Size is 8
    1 Stop Bit
    Last edited by mcbeasleyjr; - 26th May 2009 at 22:22. Reason: forgot port settings...

    Morris Beasley
    Manufacturing Test Technician
    B.S. Industrial Technology (2007)

    For more information on our robotics, please visit:
    http://www.ish-electronics.webs.com

Similar Threads

  1. Wireless serial communication question
    By Ahmadabuomar in forum Serial
    Replies: 3
    Last Post: - 21st December 2009, 03:49
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 10:52
  4. Serial Communication using 12F629
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2005, 04:24
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts