title: transferring a number using serial port
body: <p>I want to write a program to read a number from dipswitch and transfer that number using rs232 protocol(serial port). this program is written in assembly language. I have used PORTB as an input port and it is connected to dipswitch in order to get the number that is supposed to transmit. I simulated this protocol in proteus but it doesn't show anything as a result. what's wrong?</p>
  
  <p>PROTEUS SIMULATION -</p>
  
  <p><a href="https://i.stack.imgur.com/iZ33M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iZ33M.png" alt="Screenshot"></a></p>
  
  <p>here is the code:</p>
  
  <pre><code>#include&lt;p18f2550.inc&gt;
  
  ; CONFIG1H
   config FOSC =HS      ; Oscillator Selection bits (HS oscillator (HS))
  
  ; CONFIG2H
   config WDT = OFF        ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
   config WDTPS = 32768    ; Watchdog Timer Postscale Select bits (1:32768)
  
  
  ORG 0X00
  GOTO MAIN
  
  MAIN:
  MOVLW B'00100000' ;enable transmit and choose low baud
  MOVWF TXSTA ;write to reg
  MOVLW D'15' ;9600 bps
  MOVWF SPBRG ;write to reg
  BCF TRISC, TX ;make tx pin and output pin
  BSF RCSTA, SPEN ;enable the serial port
  SETF TRISB ;portb defined as input
  
  OVER:
  MOVFF PORTB,W ;move portb to wreg
  CALL TRANS
  
  
  TRANS:
  S1
  BTFSS PIR1, TXIF ;wait until last bit is gone
  BRA S1 ;stay in loop
  MOVWF TXREG ;load th value to e transmitted
  CALL OVER
  
  END
  </code></pre>