EUASRT FOR 18F4550
SPBRGH:SPBRG: X = ((FOSC/Desired Baud Rate)/64) – 1
X = 12000000/9600/61 - 1 = 18.53125
so baudrate generators should be loaded with 18.
your actual baudrate will be
Baud Rate = 12000000/(64 (18 + 1)) = 9868
error = 9868 - 9600 / 9600 = 2.8%
too much error so your terminal may or may not get the right characters. try loading your SPBRG with 18 and see if it works. if not then its better to change crystal as you can see from above equation error %age is too high for asynchronous communication.
That divides by 16 giving a much better accuracy.
[ Edited Sun Jun 09 2013, 04:38 am ]
Actually I should have said flash an LED using a timer.
Can you post the code you used.
If you use a built in delay or a loop it may not mean anything.
If the LED flashes at the calculated rate the crystal must be working at the right speed.
I think your value of 77 is correct, and should be accurate enough to work.ExperimenterUK
i didn't get that..abdul991
We need a way to check your clock speeds.
Use the inbuilt hardware timers to create periods of 1 second.
By comparing the actual period to the one expected we can see any error,
and start to work out the cause.
#pragma config PLLDIV = 2
#pragma config FOSC = HS
in the earlier program i added.....
hello i m also facing this problem for 2-4 days.
actually i have done my GSM based project with PIC18F4520 successfully and i was doing what i want , through serial communication and GSM module. Unfortunately i have lost my PIC18F4520 but i had PIC18F4550 so i had just generated hex code using same code with little modification like PIC 18F4550 in place of PIC18F4520 with my compiler mikroC .
now i m getting undesirable result . and all thing is very slow.
To check i write a simple serial program to send data from pic18F4520 it working on protius.
my prgram is..
void main(void) { unsigned char z; unsigned char masg[]="how r you\r"; TXSTA=0x20; SPBRG=0x12; TXSTA.TXEN=1; RCSTA.SPEN=1; while(1) { for(z=0;z<=15;z++) { while(PIR1.TXIF==0); TXREG=masg[z]; Delay_ms(20); } } }
but same program when i write for PIC18F4550 it is not working i m not getting any thing on terminal.
i use some sfr and use this in my code(above program) to see above post like ..
BAUDCON = 0x40;
TXSTA = 0x24;
i m getting some some garbage data.
where is problem sir.
[ Edited Tue Sep 10 2013, 10:34 pm ]
with pic18f4520.
with PIC18F4550
[ Edited Tue Sep 10 2013, 01:41 pm ]
Dear sir,
hello i m also facing this problem for 2-4 days.
actually i have done my GSM based project with PIC18F4520 successfully and i was doing what i want , through serial communication and GSM module. Unfortunately i have lost my PIC18F4520 but i had PIC18F4550 so i had just generated hex code using same code with little modification like PIC 18F4550 in place of PIC18F4520 with my compiler mikroC .
now i m getting undesirable result . and all thing is very slow.dspicmicro
As in abdul991's case, the most likely cause is the configuration bits.
How are your configuration bits set ?