CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Baudrate of PIC 12Mhz question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gelio



Joined: 25 Aug 2014
Posts: 12

View user's profile Send private message

Baudrate of PIC 12Mhz question
PostPosted: Mon Aug 25, 2014 7:14 am     Reply with quote

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: 19498

View user's profile Send private message

PostPosted: Mon Aug 25, 2014 7:26 am     Reply with quote

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: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Aug 25, 2014 7:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 25, 2014 1:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 25, 2014 1:11 pm     Reply with quote

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: 19498

View user's profile Send private message

PostPosted: Mon Aug 25, 2014 1:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 26, 2014 1:20 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group