RS232 routine for 14-bit PIC cores. TX only, fixed 115200 bps, 3.6864MHz XTAL, no parity.
Note : Tested only in a PIC6F628A. Free for personal use. If you use
it, please mention my name, or at least where you found this.
;C. Blondin (Fenugrec), 16/12/2006
;sends the byte in W through RB6,
;but it should work with any pin & any port
;(you can change the relevant bitmasks)
;uses a shadow reg, assumes no interrupts during execution.
;also needs two GPRs : count and TXbyte.
;STATUS is modified.
;1 bit @ 115200bps gives 8.68 us / bit;
;1 TCy @ 3.6864 MHz gives 1.085 us;
;total of 8 instructions / bit for the sending
bcf STATUS,C ;prepare startbit
movlw 09 ;startbit + 8 bits
andlw b'10111111' ;RB6 = 0 ;1
btfsc STATUS,C ;1
iorlw b'01000000' ;else 1 ;1
movwf PORTB ;1 X
rrf TXbyte,F ;LSb first ;1
decfsz count,F ;1
goto _TX_shiftloop ;2
iorlw b'01000000' ;1
movwf sPORTB ;1
goto $+1 ;lastbit = 8TCy ;2
movwf PORTB ;set RB6 high ;1 _/
| ||©2022 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?|
<A HREF="http://www.sxlist.com/techref/member/csblondin-sympatico-/Ser-rout.htm"> RS232 routine for 14-bit PIC cores. TX only, fixed 115200 bps, 3.6864MHz XTAL, no parity.</A>