please dont rip this site

PIC Specific RS232 routine

by Tony Nixon


This code is written for a 16C74, but it should still work.

One difference with the 16F877 is the RCSTA register which has a ADDEN bit, but this is disabled on powerup.

; enable ASYNC TX/RX
;
; BAUD RATE SETTINGS
; 38400 - spbrg = 25, brgh = 1
; 19200 - spbrg = 12, brgh = 0
; 9600  - spbrg = 25, brgh = 0
;
          movlw b'01xxxxxx'
          movwf portc
          bsf status,rp0
          movlw b'10xxxxxx'   ; x = depends on your application
          movwf trisC

          movlw d'12'         ; 19200 baud
          movwf spbrg
          movlw b'00100000'    ; brgh = low
          ; movlw b'00100100'   ; brgh = high
          movwf txsta         ; enable Async Transmission, set brgh
          bcf status,rp0      ; ram page 0
          movlw b'10010000'
          movwf rcsta         ; enable Async Reception
          movf rcreg,w        ; flush receive buffer
          movf rcreg,w        ; maybe not needed
          movf rcreg,w

;
; Perhaps put a powerup settling time delay here
;


; program start
; receive a character and echo it back

Loop
          call Receive          ; -> RxHold

          movf RxHold,w
          movwf txreg

          goto Loop
;
; ----------------------------
; RECEIVE CHARACTER FROM RS232
; ----------------------------
; This routine does not return until a character is received.

Receive   nop
          btfss pir1,rcif     ; (5) check for received data
          goto Receive

          movf rcreg,w
          movwf RxHold        ; tempstore data
          return

-- Best regards

Tony

http://www.bubblesoftonline.com
mailto:spamsalesSPAM at -Remove-picnpoke.com

See also:

  1. http://www.infosite.com/%7Ejkeyzer/piclist/2000/Feb/1374.html

file: /Techref/microchip/pprs232.htm, 2KB, , updated: 2001/5/25 14:48, local time: 2020/7/3 06:48,
TOP NEW HELP FIND: 
3.236.97.49:LOG IN

 ©2020 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.piclist.com/techref/microchip/pprs232.htm"> PIC Specific RS232 routine</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 
Quick, and RELIABLE! RCL-1 RS232 Level Converter in a DB9 backshell only $25.00
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232!
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .