[SOLVED] Baud rate synchronization error [Micro-controller : pic18f46j11 ]

Status
Not open for further replies.

fag.bhu

Newbie level 4
Joined
Jan 1, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,358
hi ,

I am trying to send few AT Commands from my PIC Controller to the modem ....... I observed that my Controller is sending the AT commands correctly at 9600 baud rate..... But it sends garbage values at 115200 baud rate....

According to the requirements mentioned in my Modem's Manual ..... I need to send the AT Commands at 115200 baud rate.

So, I am not able to find any solution for this issue .... Please suggest some fixes for the same ....

The baud rate count which i am loading in my controller i.e in my SPBRG register , and other related details are as under :

Count for 9600 baud rate using 16MHZ crystal : 25 (Exact value : 25.04) (Working with the Controller)
Count for 115200 baud rate using 16MHZ crystal : 1 (Exact value : 1.17) (Not Working i.e throws garbage value at the modem)
desired baud rate for my modem : 115200
formula used : ((Fosc/baud rate)/64)-1
please highlight the problem in my system ...... i want to send my AT commands at 115200 baud rate from my controller without garbage value ......


the initialization program goes like this :

#INCLUDE<P18F46J11.INC>0

CONFIG OSC=HS

R2 EQU 0X40

R3 EQU 0X44

R4 EQU 0X48

ORG 0
MOVLW 0x20 ;enable transmit and low baud rate

MOVWF TXSTA

MOVLW D'25' ;115200 BPS at 16MHZ

MOVWF SPBRG1

BSF RCSTA,SPEN; enable the serial port



revert asap .....

regards,
fag
 

It's simply a case of not being able to generate the higher baud rate accurately enough with that crystal frequency. You need to get within a couple of percent or better. It's not that your PIC is sending gibberish, it's just sending at an inaccurate rate so the receiver sees gibberish.

Your crystal frequency gives an error of 17% at 115000 baud... no way that will work. Think, after six bits, the next bit is more than a full bit out of expected step.

Use a different crystal frequency.

Example: 14.7456MHz crystal, ((14745600/115200)/64)-1 = 1 exactly (perfect rate)

Note also that you can use a different frequency divisor (I think) on that PIC; check the data sheet. You can set it at 16, not 64, so your error will be a quarter.

That would make your ((16MHz/115000)/16)-1 = 7.7 so set to 8 is 4% error - that's still not good but might or might not work depending on what you connect to.

I would choose a better crystal for reliable 115000 baud.


Edit to add:

I think you can also do a /4 clock mode (set SFR bits BRGH and BRG16 to 1), so your case would become:

((16MHz/115000)/4)-1 = 33.72 so set to 34 is 0.8% error... that should work.
 
Last edited:
It rather sounds like a trivial autobaud problem. To make the modem's autobaud feature work correctly, you need to send individual characters 'A' and 'T' with surrounding delay, as if typed manually at Hyperterminal. Fixing the baud rate in nonvolatile modem setup is another option.
 

thank you for the advise ... it worked out well for me .....
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…