; list p=16F84, f=inhx8m ;Enter device name ;printed on the probe ;connected to your pod. include ;RS232 transmit function ; assume 10mHz clock ; instruction cycle of .4uS count EQU H'000C' txreg EQU H'000D' delay EQU H'000E' MCount EQU H'000F' clockrate EQU 10000000 baudrate EQU 9600 fclk EQU clockrate/4 baudconst EQU .85 ;((fclk/baudrate)- 2)/3 baudhalf EQU baudconst >> 2 #define _tx PORTA, 0 #define _rx PORTA, 1 org 0 ;start address 0 clrf PORTA bsf STATUS, RP0 movlw B'01010' movwf TRISA bcf STATUS, RP0 bsf _tx nop nop nop loop2 ; movlw D'10' ; movwf MCount ;movlw 'U' ;call Xmtr ;Loop ; movf MCount,w ; call Table ; call Xmtr ; decfsz MCount,f ; goto Loop call Rcvr addlw 1 call Xmtr goto loop2 Table addwf PCL retlw ' ' retlw 't' retlw 'm' retlw 'X' retlw ' ' retlw '2' retlw '3' retlw '2' retlw 'S' retlw 'R' retlw '*' Xmtr movwf txreg movlw 8 movwf count bcf _tx ; Start bit X_next call WaitOneBit ; Wait one bit width rrf txreg, F ; Output the next data bit btfsc STATUS, C bsf _tx btfss STATUS, C bcf _tx decfsz count, f goto X_next ; Repeat call WaitOneBit ; Wait one bit width bsf _tx ; Stop bit call WaitOneBit return Rcvr btfsc _rx ; Wait for the start bit goto Rcvr call WaitHalfBit ; Wait through half of the first bit movlw 8 movwf count clrf txreg R_next call WaitOneBit ; Wait through the previous bit bcf STATUS, C btfsc _rx bsf STATUS, C rrf txreg, F decfsz count, F goto R_next call WaitOneBit ; Wait through the stop bit movf txreg, W return WaitOneBit movlw baudconst ; Wait one bit width movwf delay txbaudwait decfsz delay, f goto txbaudwait return WaitHalfBit movlw baudhalf movwf delay txbaudwaithalf decfsz delay, f goto txbaudwaithalf return end