Discussion in "PIC Microcontroller Discussion" started by    abdul991    May 28, 2013.
Fri Jun 07 2013, 04:53 pm
#11
i didn't get that.. i'm using MPLAB IDE with C18 Compiler
Sat Jun 08 2013, 11:12 am
#12
for 12Mhz @9600 as per my equation value comes out to be
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.
 abdul991 like this.
Sat Jun 08 2013, 11:46 pm
#13
abdul991 is setting BRGH =1
That divides by 16 giving a much better accuracy.


[ Edited Sun Jun 09 2013, 04:38 am ]
Sun Jun 09 2013, 01:19 am
#14



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.
Wed Aug 21 2013, 07:31 am
#15
problem solved... it was the configuration bits that required to be properly set; i.e.,

#pragma config PLLDIV = 2
#pragma config FOSC = HS

in the earlier program i added.....
Thu Aug 22 2013, 12:06 pm
#16
congrats we usually assume person knows about config bits before flashing code.
Tue Sep 10 2013, 01:13 pm
#17
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.
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 ]
Tue Sep 10 2013, 01:37 pm
#18
here is both out put.
with pic18f4520.


with PIC18F4550


[ Edited Tue Sep 10 2013, 01:41 pm ]
Tue Sep 10 2013, 11:48 pm
#19


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 ?
Wed Sep 11 2013, 10:01 am
#20
Did you check clocking of both controllers? is it same?

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am