Searching \ for 'ASCII driver code for PIC16C73!!!' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=16C
Search entire site for: 'ASCII driver code for PIC16C73!!!'.

Truncated match.
PICList Thread
'ASCII driver code for PIC16C73!!!'
2000\02\24@095317 by Thomas C. Sefranek

face picon face
I (think) I finally have deciphered the drive requirements for these
PICs.
I have several working PICs now successfully driving Character strings.

WARNING:  You MUST set both I/O bits to input on PORTC!
(Even though one line is an OUTPUT!!!)

WARNING:  You must not trust the TXIF bit to accurately reflect the
state
of the transmitter on power up.
(The flag shows FULL even though there are NO characters in either the
TXREG
or TSR!  The flag bit TXIF is ONLY true AFTER the first DUMMY
character's
STOP bit is clocked out of the TSR producing the FIRST load pulse to
the TXREG
and setting the correct flags!)



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  spam_OUTtcsTakeThisOuTspamcmcorp.com
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41, 448.625 Mhz

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

2000\02\24@163815 by Tony Nixon

flavicon
picon face
"Thomas C. Sefranek" wrote:

> WARNING:  You MUST set both I/O bits to input on PORTC!
> (Even though one line is an OUTPUT!!!)

I have never done this on any PIC I have used, and have had no problems
to date.
I have always set the TX pin to an output.

--
Best regards

Tony

http://www.picnpoke.com
.....salesKILLspamspam@spam@picnpoke.com

2000\02\25@150106 by Thomas C. Sefranek

face picon face
Tony Nixon wrote:

> "Thomas C. Sefranek" wrote:
>
> > WARNING:  You MUST set both I/O bits to input on PORTC!
> > (Even though one line is an OUTPUT!!!)
>
> I have never done this on any PIC I have used, and have had no problems
> to date.
> I have always set the TX pin to an output.

O.K.  I tried it today!
19,2K baud, PIC16C73A
Set bit 6 (PORTC) to output, it DOES NOT work!
Set bit back to input, IT WORKS!
Set bit back to output (0),  it DOES NOT work!
Set bit back to input, IT WORKS!

Seems pretty straight forward to me.

> --
> Best regards
>
> Tony
>
> http://www.picnpoke.com
> salesspamKILLspampicnpoke.com

--
 *
 |  __O    Thomas C. Sefranek  .....tcsKILLspamspam.....cmcorp.com
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41, 448.625 Mhz

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

2000\02\25@181219 by Cherry, Neil J, SOCOO

picon face
>Tony Nixon wrote:
>
>> "Thomas C. Sefranek" wrote:
>>
>> > WARNING:  You MUST set both I/O bits to input on PORTC!
>> > (Even though one line is an OUTPUT!!!)
>>
>> I have never done this on any PIC I have used, and have had no problems
>> to date.
>> I have always set the TX pin to an output.
>
>O.K.  I tried it today!
>19,2K baud, PIC16C73A
>Set bit 6 (PORTC) to output, it DOES NOT work!
>Set bit back to input, IT WORKS!
>Set bit back to output (0),  it DOES NOT work!
>Set bit back to input, IT WORKS!
>
>Seems pretty straight forward to me.

Seems like they fixed that on the 16F877. I set the TX to output
and the RX as input. It does seem weird, doesn't it!

Neil Cherry

2000\02\26@031116 by Tom Handley

picon face
  Neil, Tom, and Tony, the `bottom line' is that all the data books,
for all the PIC 16x devices that have USARTs, have always said and still
do, that they should both be inputs. The choice seems simple to me...

  - Tom

At 06:09 PM 2/25/00 -0500, Cherry, Neil J, SOCOO wrote:
{Quote hidden}

------------------------------------------------------------------------
Tom Handley
New Age Communications
Since '75 before "New Age" and no one around here is waiting for UFOs ;-)

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...