please dont rip this site

PIC Specific RS232 routine

Thomas C. Sefranek tcs at cmcorp.com says:

I have several working PICs now successfully driving Character strings.


ASSEMBLY SOURCE CODE

; A 20MHz Source is divided by 8 (Externally)
; producing a processor clock of 2.5 Mhz,
; the machine cycle clock is 625 Khz.
;
; USART clock = 2.5Mhz/64(1+1) = 19,531,25 Baud.
; (1.7% Error to 19,200 Baud)  BRGH=0

Init_PORTC      CLRF    PORTC           ; Clear all outputs.
                BSF     STATUS,RP0      ; Select Bank 1 Registers.
                MOVLW   B'11000000'     ; Form a byte to signify:
                                        ; Bits 7-6 as Inputs.
                                        ; Bit 5-0 as unused Outputs.
                MOVWF   TRISC           ; Set Port C as:
                                        ; RC<7> Serial Data In.
                                        ; RC<6> Serial Data Out.
                                        ; RC<5:0> not used.
                BCF     STATUS, RP0     ; Select Bank 0 Registers.

Init_USART      BSF     STATUS,RP0      ; Select Bank 1 Registers.
                MOVLW   1               ; Form a byte to signify 19.2 Baud rate.
                MOVWF   SPBRG           ; Set the Baud Rate Generator to 19.2 Baud Rate.
                BCF     STATUS,RP0      ; Select Bank 0 Registers.
                MOVLW   B'10010000'     ; Form a byte to signify:
                                        ; Bit 7 Serial Port enabled.
                                        ; Bit 6 Select 8 bit reception.
                                        ; Bit 5 Don't care.
                                        ; Bit 4 Enable continuous receive mode.
                                        ; Bit 3 Don't care.
                                        ; Bit 2 Framing Error.
                                        ; Bit 1 Overrun Error.
                                        ; Bit 0 9th bit.
                MOVWF   RCSTA           ; Initialize Receive Status and control register.
                BSF     STATUS,RP0      ; Select Bank 1 Registers.
                MOVLW   B'00100010'     ; Form a byte to signify:
                                        ; Bit 7 Don't care in Asynchronous mode.
                                        ; Bit 6 Select 8 bit transmission.
                                        ; Bit 5 Enable the transmitter.
                                        ; Bit 4 Select Asynchronous mode.
                                        ; Bit 3 Don't care.
                                        ; Bit 2 Select Low Speed BRG.
                                        ; Bit 1 Xmit Shift Reg. Empty.
                                        ; Bit 0 9th bit.
                MOVWF   TXSTA           ; Initialize Transmit Status/control register.
                BCF     STATUS,RP0      ; Select Bank 0 Registers.

;
;****************************** Print Character Routine
***********************
; Character is passed in "W".  If the transmitter is busy, characters
are saved
; in a FIFO.
;******************************************************************************
Print_Chr       BTFSC   FIFO_STATE,0    ; Is the FIFO in use?
                GOTO    Push_Chr        ; Yes, Push the character in the FIFO.
PR_Loop         BTFSC   PIR1,TXIF       ; No, Is the Transmitter busy?
                GOTO    Stuff_Chr       ; No, Send this character.
                BSF     STATUS,RP0      ; Yes, Select Bank 1 Registers.
                BTFSC   TXSTA,TRMT      ; Is the Shift register empty?
                GOTO    ReTest_TSR      ; Yes, Re-test for Initialization.
                BCF     STATUS, RP0     ; No, Select Bank 0 Registers.
                GOTO    Save_Chr        ; Push the character in the FIFO.
;
ReTest_TSR      BCF     STATUS, RP0     ; Select Bank 0 Registers.
                GOTO    PR_Loop         ; Yes, Look for it to clear.
;
Stuff_Chr       MOVWF   TXREG           ; No, Send this character.
                RETURN                  ; Done.
;
--
  *
  |  __O    Thomas C. Sefranek  tcs at cmcorp.com
  |_-\<,_   Amateur Radio Operator: WA1RHP
  (*)/ (*)  Bicycle mobile on 145.41, 448.625 Mhz

ARRL Instructor, Technical Specialist, VE Contact.
http://hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org

Onboard UARTS


file: /Techref/microchip/usarttcs.htm, 5KB, , updated: 2007/4/9 18:56, local time: 2024/12/22 07:47,
TOP NEW HELP FIND: 
3.139.79.187:LOG IN

 ©2024 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://massmind.ecomorder.com/Techref/microchip/usarttcs.htm"> Thomas C. Sefranek's 16C73 USART Serial Port Gotcha List and Source</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 a nice message (short messages are blocked as spam) 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?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .