PDA

View Full Version : Communicate with PC at baud rate :115200 bps



iugmoh
- 8th March 2008, 06:05
Hi all,
I woking on project communicate with Nokia 5110 through serial protocol , but I have a problem that the serial protocol must be at baud rate 115200 bps , so I try PC with PIC16f877a first. I can communicate at 9600 with higher than this the data is not true it's corrupted .
if anyone can help me ?

Archangel
- 8th March 2008, 06:22
Hello iugmoh,
Need a little more information, over what distance, what kind of wire are you using, are you using max 232 level shifters chips, are you using hand shaking, what oscillator speed is the PIC running, are you using serout, serout2, hserout . . . ? Do a search on character pacing
http://www.picbasic.co.uk/forum/showthread.php?p=3633

iugmoh
- 8th March 2008, 09:55
oky I have these things :
1- max232 converter
2- 4MHZ or 8MHZ crystal
3- PIC16F877A or PIC18f452 or PIC4220

I make a programm and put the values accoding to formula baud=fosc/(16(x+1)) or baud=fosc(64/(x+1))

but the data I recived from pic at pc is a strange data not know

Archangel
- 8th March 2008, 18:50
oky I have these things :
1- max232 converter
2- 4MHZ or 8MHZ crystal
3- PIC16F877A or PIC18f452 or PIC4220

I make a programm and put the values accoding to formula baud=fosc/(16(x+1)) or baud=fosc(64/(x+1))

but the data I recived from pic at pc is a strange data not know
"4MHZ or 8MHZ crystal" 4mhz too slow 8mhz probably too slow
go get this from mister e http://www.mister-e.org/pages/picmulticalcpag.html
using Mister_e's calculator set for 8mhz we get these settings:

RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 16 ' 115200 Baud @ 8MHz, 2.12%
SPBRGH = 0
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

You may need to slow the character pacing a bit. DEFINE CHAR_PACING 1000

BrianT
- 8th March 2008, 22:40
By default, PIC ports have their OFF or IDLE condition as zero volts. RS-232 however defines the IDLE or steady mark to be negative volts at the 25 pin connector. This means the idle condition between the PIC and the MAX232 chip must be HIGH or positive - the reverse of what you might first think.

An asynchronous character begins when the receiving device detects the transition from the steady MARK to a SPACE bit. BUT, if you did nothing to the Txoutput pin before that character started, then the line had been in the space condition for some time. i.e. the start bit goes missing and so the character is corrupted.

Try this.

HIGH Txpin 'sets the RS-232 connector pin to negative = Mark = Idle
pause 1 ' lest the line settle and the remote device see the mark condition
Serout/hserout/serout21 pin, rate, data 'the message now starts with a guaranteed start bit.

HTH
BrianT

skimask
- 9th March 2008, 05:43
I can communicate at 9600 with higher than this the data is not true it's corrupted


2- 4MHZ or 8MHZ crystal
3- PIC16F877A or PIC18f452 or PIC4220
Says right in the back of the manual that a faster clock speed than 4Mhz will most likely be needed with a 4Mhz crystal, like quite a bit faster.
If you're using a '452, turn on the 4xPLL and use the 8Mhz crystal. That'll give you 32Mhz to play with.

precision
- 9th March 2008, 06:29
But i always use 115200 Baud in nokia 3350 sms zone alarm with this code.

DEFINE OSC 12 ( I use 11.0592 mhz xtal after define osc 12 )

OUTPUT PORTC.6 '-- SERIAL Port TX
INPUT PORTC.7 '-- SERIAL Port RX

DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 5 ' 115200 Bauds with 0% error

HSEROUT [X,Y,Z]

skimask
- 9th March 2008, 07:01
But i always use 115200 Baud in nokia 3350 sms zone alarm with this code.
Well, that'll work too, because you're using the HARDWARE USART.
The note at the back of the book is for SERIN(2)/SEROUT(2).
The O/P didn't specify if hardware or software serial was being used...

iugmoh
- 9th March 2008, 07:32
SPBRGH = 0
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator



Oky with PIC16f877a this give me an error because theses registers are not exist

skimask
- 9th March 2008, 07:45
Oky with PIC16f877a this give me an error because theses registers are not exist

And a quick look at the '877A datasheet, Table 10-3, would tell you that getting 115,200 baud out of 4 or 8 Mhz isn't going to happen, unless you can somehow magically get a divisor of 1.5 stuff into that byte value.
You need more crystals in your toolbox.
Actually, what you need is more variety...

iugmoh
- 9th March 2008, 08:15
ok what is the suitable PIC IC needed with crystal to achive this problem

skimask
- 9th March 2008, 08:25
ok what is the suitable PIC IC needed with crystal to achive this problem

FASTER...that's all...FASTER! Read the Tables and you'll see what I mean.
A serial link can tolerate X amount of error. So, find the combination of oscillator speeds and serial communication speeds that works for your unique situation.
I can't help you much more than that...I don't think anybody can...until you do some reading and comprehending the information involved.
The 16F877A will run at 20Mhz (possibly a bit faster), the 18Fxxxx series will run at 40Mhz (55Mhz in my experience, but not recommended for reliability). Either of those chips that you have been relating to in your threads will work just fine.
You need more crystals! More oscillators! More freq! More cycles per second! More HERTZ! More variances of direct current per unit of time!
That's all!

precision
- 9th March 2008, 09:16
Well, that'll work too, because you're using the HARDWARE USART.
The note at the back of the book is for SERIN(2)/SEROUT(2).
The O/P didn't specify if hardware or software serial was being used...

You 'r right skimask,
We cannot achive 115200 baud with SERIN2, According to manual and limitation of compiler,
But i think one day we all will use SERIN2 at 115200 baud as below,

DEFINE OSC 20
INCLUDE "My_Lcd.bas"
INCLUDE "DT_INTS-14.bas"
INCLUDE "LCDbar_INC.bas"
INCLUDE "DT_INS-SERIN2.bas"


B0 var word
Main:
@ DT_SERIN2 , 115200, [B0]

LCDOUT $fe,1, "Value", DEC 5 B0
pause 200
goto main

Sory Sir Darrel Taylor, its impossible for us to achive 115200 baud in serin2 mode without your MAGIC code.

skimask
- 9th March 2008, 09:25
You 'r right skimask,
We cannot achive 115200 baud with SERIN2, According to manual and limitation of compiler,
But i think one day we all will use SERIN2 at 115200 baud as below,

I don't know if it works or not...but...
If you DEFINE OSC 4...
then try to run DEBUG at 9600...
but actually clock your PIC at 48Mhz...
(or DEFINE OSC 4, run DEBUG at 19200 and clock at 24Mhz)
You MIGHT get 115,200.
Don't know how reliable it'll be though...

iugmoh
- 20th March 2008, 13:54
Oky Here is the code after trial it on PIC16f877a to communicate with PC at 115200 bps baud rate and it's working fine without any error
===============================================
DEFINE OSC 20
' Set receive register to receiver enabled
DEFINE HSER_RCSTA 90h

' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 24h

' Set baud rate
DEFINE HSER_BAUD 115200

' Set SPBRG directly (normally set by HSER_BAUD)
DEFINE HSER_SPBRG 10

main:
HSEROUT ["yes its working",13,10]
pause 300
goto main

end