Trying to learn HSERX usage


+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013
    Posts
    32

    Default Trying to learn HSERX usage

    Hi guys, I didn't use serial communication before ad now I'm trying to learn basics with a simple circuit. I wandered on forums and read most of topics but can't find where my mistake is.
    I'm trying to establish a serial communication between 2 16f877a. First one has switches on portb, reading then sending them via serial with hserout. Second one has leds on portb, receiving data from serial and then writing on portb.
    Altough its a very simple circuit, I cannot make it work. I simulate circuit on protheus, it looks like data is transmitting from first one but can't proccess it on second I think. Can't find the problem, can you help me please? here are my codes.
    Note; I commented out some lines from original code to make things simplier for trying.

    Transmitter Code
    Code:
    TRISB=111111
    TRISC=000000
    TRISD=000001
    define OSC 16
    DEFINE HSER_RCSTA 90h '(alma yazmacının Enable edilmesi)
    DEFINE HSER_TXSTA 20h '(gönderme yazmacının Enable edilmesi)
    DEFINE HSER_BAUD 9600 '(Haberlesme hızının belirlenmesi)
    PORTB=0
    PORTC=0
    PORTD=0
    veri var byte
    lastveri var byte
    symbol bt0=PORTD.0
    clear
    
    
    basla:
    'if bt0=0 then
        veri=PORTB
    'endif
    'if veri!=lastveri then
    '    lastveri=veri
        hserout [veri]
        while not TXSTA.1 : WEND
        
    'endif
    goto basla
    end
    Receiver Code
    Code:
    TRISB=000000
    TRISC=000000
    define OSC 16
    DEFINE HSER_RCSTA 90h '(alma yazmacının Enable edilmesi)
    DEFINE HSER_TXSTA 20h '(gönderme yazmacının Enable edilmesi)
    DEFINE HSER_BAUD 9600 '(Haberlesme hızının belirlenmesi)
    PORTB=0
    PORTC=0
    veri1 var byte
    lastveri1 var byte
    clear
    
    
    basla1:
    hserin [veri1]
    while not PIR1.5 : wend
    'if veri!=lastveri then
    '    lastveri=veri
        PORTB=veri1
    
    
    'endif
    goto basla1
    end

  2. #2
    Join Date
    Apr 2013
    Posts
    32

    Default Re: Trying to learn HSERX usage

    I found the problem, it looks like both of transmit and receive pins must be set as inputs. Otherwise it doesn't work. Hope this helps other beginners =)

Similar Threads

  1. How/where to learn Assembly?
    By HankMcSpank in forum General
    Replies: 6
    Last Post: - 9th August 2011, 17:40
  2. How do you learn best?
    By T.Jackson in forum Off Topic
    Replies: 41
    Last Post: - 30th May 2008, 14:32
  3. The easiest way to learn how to program
    By T.Jackson in forum Off Topic
    Replies: 19
    Last Post: - 7th April 2008, 05:04
  4. How to learn assembely?
    By amindzo in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 26th May 2007, 21:23
  5. Who wants to learn...
    By Stoverus in forum Off Topic
    Replies: 1
    Last Post: - 21st October 2006, 07:08

Posting Permissions

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