Searching \ for '[PIC] Re: PIC16F877 & USART' 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/ios.htm?key=usart
Search entire site for: 'Re: PIC16F877 & USART'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Re: PIC16F877 & USART'
2002\12\29@132953 by Dennis Crawley

flavicon
face
part 1 821 bytes content-type:text/plain; (decoded 7bit)


Rick:

The secret is the chrystal selection if your applcation gonna be full
dedicated to serial communications. (divisible by powers of 2).
BRGH is used to get an accurate scan of the start bit and the rest of the
bits.
Take a minute and read thoroughly the data sheet. I recommend that you read
also the  16F62x datasheet on the same subject.
Basically play with the formulas on a spreadsheet or use this "dirty" soft
to calculate the error percentage, and note the difference between brgh=1
and brgh=0
Oh! is in Spanish but it is not a big deal, you figured out!.
Best wishes,
Dennis.

PS:
we'd better put the [pic] tag or...

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics




part 2 23904 bytes content-type:application/x-zip-compressed; (decode)

part 3 2 bytes
-

2002\12\29@134035 by Spehro Pefhany

picon face
At 03:27 PM 12/29/02 -0300, you wrote:

>Oh! is in Spanish but it is not a big deal, you figured out!.
>Best wishes,
>Dennis.

Handy, but the error handling could be improved. ;-)

----
Ingrese BaudRate en bps:600
Ingrese el valor del cristal en hz:32768

Division by zero in line 56199 of module ¦ç__µ at address FD28:2897
----

Thanks & Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
spam_OUTspeffTakeThisOuTspaminterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2002\12\29@145207 by Dennis Crawley

flavicon
face
Spehro:

>Handy, but the error handling could be improved. ;-)
>----
>Ingrese BaudRate en bps:600
>Ingrese el valor del cristal en hz:32768
>Division by zero in line 56199 of module &g__5 at address FD28:2897
>----
>Thanks & Best regards,

:-), Yeah, that's why I wrote "dirty",...
I suppose someone can improves this for all new guys.
In C would be better and shorter. Also the SPBRG calculation can be
adjusted for rounding errors using Tony K|bek formula:
; calculates baudrate when BRGH = 1, adjust for rounding errors
;* spbrg_value = (((d'10'*XTAL_FREQ/(d'16'*baudrate))+d'5')/d'10')-1
;*
;* ; calculates baudrate when BRGH = 0, adjust for rounding errors
;* spbrg_value = (((d'10'*XTAL_FREQ/(d'64'*baudrate))+d'5')/d'10')-1
(Ripped from Thomas McGahee Picusart,... wherever he is. ?Where is he?)


Here is my "old-qbasic-dirty" code:

INPUT "Ingrese BaudRate en bps:", Baud
INPUT "Ingrese el valor del cristal en hz:", Fosc

BRGH0 = 64
BRGH1 = 16
SPBRG0 = INT(Fosc / BRGH0 / Baud) - 1
SPBRG1 = INT(Fosc / BRGH1 / Baud) - 1
CalcBaud0 = INT(Fosc / (BRGH0 * (SPBRG0 + 1)))
CalcBaud1 = INT(Fosc / (BRGH1 * (SPBRG1 + 1)))
Error0 = (CalcBaud0 - Baud) / Baud
Error1 = (CalcBaud1 - Baud) / Baud

a$ = RIGHT$("        " + STR$(Baud), 10)
b$ = RIGHT$("        " + STR$(Fosc), 10)
c$ = RIGHT$("        " + STR$(BRGH1), 10)
d$ = RIGHT$("        " + STR$(BRGH0), 10)
e$ = RIGHT$("        " + STR$(SPBRG1), 10)
F$ = RIGHT$("        " + STR$(SPBRG0), 10)
g$ = RIGHT$("        " + STR$(CalcBaud1), 10)
h$ = RIGHT$("        " + STR$(CalcBaud0), 10)
i$ = RIGHT$("        " + MID$(LEFT$(STR$(Error1 * 100), 4), 1) + "%", 10)
j$ = RIGHT$("        " + MID$(LEFT$(STR$(Error0 * 100), 4), 1) + "%", 10)

PRINT "                BRGH=1    BRGH=0"
PRINT
PRINT " Brate      "; a$; a$
PRINT " Focs       "; b$; b$
PRINT " BRGH       "; c$; d$
PRINT " SPBRG      "; e$; F$
PRINT " CalcBRate  "; g$; h$
PRINT " Error      "; i$; j$

Regards,
Dennis


Ahora podis usar Yahoo! Messenger desde tu celular. Aprendi csmo hacerlo en Yahoo! Msvil: http://ar.mobile.yahoo.com/sms.html

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

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