View previous topic :: View next topic |
Author |
Message |
Gelio
Joined: 25 Aug 2014 Posts: 12
|
Baudrate of PIC 12Mhz question |
Posted: Mon Aug 25, 2014 7:14 am |
|
|
Hello!
please, help me to choose right baudrate settings.
My target based on PIC18F4550 with external 12Mhz crystal.
configuration settings are:
I'm trying to initialize UART mode in MPASM and setting the
SPBRG = 25
to get the 57600 baud with small error (57692) according to SPBRG calculator.
Also, I'm testing it on Proteus with Virtual Terminal and i get invalid output in it.
What method or correct calculation of SPBRG in this case?
USB mode is hi-speed.
CAN it be Proteus problem or my mistake?
thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Aug 25, 2014 7:26 am |
|
|
That doesn't look like CCS.
With CCS, you just tell it the baud rate, and never touch SPBRG, it does it for you.
This is a CCS forum.
Your settings are wrong though, your CPU is _not_ running at 12MHz.
Read the data sheet. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon Aug 25, 2014 7:58 am |
|
|
That looks like PBPro to me....
silly and confusing...I tried it 1/2 dozen times....took WAY too long to cut WORKING code(1/2 day with PBPro, 12 minutes with CCS !!)
made me very,very happy I'm still using CCS C since v2.542 !!
also read PIC101.....and you'll understand that 1/2 your problems are with Proteus.
sigh.....another set of students already ???
jay |
|
|
Gelio
Joined: 25 Aug 2014 Posts: 12
|
|
Posted: Mon Aug 25, 2014 1:00 pm |
|
|
Ok,understand. Thanks for pointing me.
Are there some example for PIC with CCS C?
i need to use UART communication with PIC18F4550.
Please, can you post some example of using it on any PIC device using CCS C functions with setting the baudrates.
Thanks! |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Mon Aug 25, 2014 1:11 pm |
|
|
There are thousands here...
Try using the search feature and put in the search block: #use rs232
Select Search for All Terms
Here is one...
http://www.ccsinfo.com/forum/viewtopic.php?t=52703 _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Aug 25, 2014 1:17 pm |
|
|
Also search for threads about the 184550 oscillator settings.
As I've already said, your chip is _not_ configured for 12MHz.
Proteus will 'believe' the clock rate you tell it. A real chip won't. |
|
|
Gelio
Joined: 25 Aug 2014 Posts: 12
|
|
Posted: Tue Aug 26, 2014 1:20 am |
|
|
Thanks for your replies, i did such thing.
i changed Crystal to common used 20Mhz.
then i made small piece of code inside CCS like
#use DELAY (crystal=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7)
void main()
{
putc('!');
};
And i realised in listing the correct configuration bits.
i compiled code and put in into proteus model and seems is works corectly now :-)
so i got needed values from assemble listing generated by CCS compiler.
Really nice. It set all the needed parameters. |
|
|
|