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 support@ccsinfo.com

UART,SPI,I2C

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



Joined: 12 Mar 2006
Posts: 20

View user's profile Send private message

UART,SPI,I2C
PostPosted: Tue Dec 18, 2007 10:20 am     Reply with quote

i'm newbie in PIC, can anyone tell me what the different between UART, SPI and I2C? and what is the relation rs232 serial protocol...thanks for your help
Ttelmah
Guest







PostPosted: Tue Dec 18, 2007 11:23 am     Reply with quote

Actually quite complex!....
The 'UART' (normally 'USART'), stands for 'Universal Asynchronous Receiver/Transmitter'. This is the hardware part in the chip, that can develop the serial _timings_ associated wth a number of communication formats (including RS232). 'USART', because many of the chips also include synchronous handling as well on the same peripheral. Now, RS232, RS485, RS232, etc., describe _signalling_ standards, often used to carry such asyncronous data. So, the UART, when programmed correctly, and combined with a hardware buffer (like the MAX232), can then generate 'RS232 serial communications'. However when combined with a MAX485 instead, the same part generates RS485 instead. Then, on each of these signalling standards, there are then 'protocols' used to specify how the communication is formatted (normally on RS232, only the 'layout' of the bytes, but on RS485, there are complete packet specifications for things like Profibus as well.
There are other serial formats used for different things. 'SPI', is a much higher speed 'local' bus used to talk to chips attached close to the main processor. Fast, synchronous (hence has a separate clock), with data transmitted both ways at once, to a _single_ peripheral. For multiple peripherals, separate 'enable' lines are needed. I2C, is another local bus, using slightly more rugged signalling (slightly lower speed, with 'open collector' drives, so that potentially multiple devices can exist on the one bus, and a single wire, can transfer data in both directions).
For both these busses, there is a 'master' that generates the timings, while for the async forms, this is not the case.
In each case, you have a signalling standard, then a data format, and finally a protocol involved. On I2C, the name defines all three parts. On RS232/485, the name only actually describes the signalling used.
The terms are often incorrectly used. So (for instance), on the CCS compiler, we have the #USE RS232 statement, yet this statement, does _not_ generate 'RS232'. Exactly the same statement is used in the RS485 example. R232, is _not_ actually a 'protocol', it is an electrical 'interface' definition. Unfortunately, the terms have become severely 'blurred', and 'RS232', is often used to refer to TTL (5v) asynch comms, as well as it's proper meaning.
In general, I2C, will be the commonest interface to talk to a lot of chips. Versions, are also available to handle larger distances. SPI, is faster, and slightly rarer, but is becoming more commonly used, again to talk to chips, especially at shorter ranges. RS232 serial, is probably the commonest interface used to talk to the PC from a PIC, or between boards.
The PICs have a number of hardware components, designed to help handle these busses, and the UART, is commonly used to generate RS232 - with the right buffer (though can also be used for some forms of SPI, in the case of units supporting 'sync' comms). The MSSP, is the hardware module designed to develop SPI, and I2C. In each case, 'partial' versions of each interface can also be developed without the hardware, using just software solutions - so in the case of I2C, a 'master' can easily be generated in software, while a 'slave' is very hard.
You need to do some research, read the data sheets,and perhaps look at some examples, to begin to understand each bus. Then more specific questions, should be able to help.

Best Wishes
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

+++++ !!!
PostPosted: Tue Dec 18, 2007 1:33 pm     Reply with quote

This is one of those brilliant answers that one is sorry that they finish diluted between
so many others...
Not only the contents itself but the time used for such intention is highly valueable. Exclamation

In view that this forum is continuously visited by many young people who are beginning
in the wonderful world of MCU´s, C Language and all that it implies, it would be very
interesting to include a new section like: "Basic knowledge" where we could start
constructing a knowledge base documents with full explanations on differents basic
aspects from a MCU and not to repeat this type of explanations time and time again.

I guess that searching in the forum we have enough info to complete the most of them,
it would be a matter of select and edit.

I would like to know your opinions regarding this.


Humberto
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

Basic knowledge
PostPosted: Tue Dec 18, 2007 2:37 pm     Reply with quote

definitly agree. not many times can see a deep answer, easy to understand to young (and not young but new in the subject) people.
the time invested in the specific answer worth appreciation.
the "Basic knowledge" is a great idea.
joseph
handsprince



Joined: 12 Mar 2006
Posts: 20

View user's profile Send private message

PostPosted: Wed Dec 19, 2007 5:39 am     Reply with quote

I agree with you all..
rlgreen



Joined: 07 Dec 2007
Posts: 8

View user's profile Send private message

PostPosted: Fri Dec 21, 2007 11:19 pm     Reply with quote

Searches do not alway provide the answers. Remember also, that we are dealing with a "Compiler", that we sometimes don't understand completly. The library functions are not public. So, "we" can't know what they are doing.

The CCS compiler is an expensive product, which we have chosen to purchase. The help we recieve on these forums is "Priceless". Without open source code to the library's, it can be tough to get your programs to work! The documentation is not very good in my opinion, so I look to the forums to increase my knowledge.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Dec 22, 2007 10:10 am     Reply with quote

The idea of Base Knowledge was to collect -in a know space in this site- all those brilliant
and remarkable explanations already posted for any contributors of this forum.
The main purpose is to keep visible and easily accesible in such way that do not lose it
in tons of threads that fortunately have this forum.
By no way it will replace a good book, but it would complement it.
This becomes necessary and practical having in mind that to search for a subject in
phpBB is an unpredictable task.

We expect that a newbie do not try to learn everything here, instead he/she would have
enough background knowledge of MCU and C Language theory, have some skills with the
electronics hardware involved but needs a small push to get the grasp to understand a
whole concept or how these stuffs interacts when all is running together(Hardware+MCU+CCS Compiler).
Schooling it is not the main purpose of this forum, but this does not implies that
anybody can learn by itself reading the contents of this forum.

In this forum nobody likes to explain Ohms Law nor that an int size in CCS is 255
nor that an I2C bus needs some pull up resistors over and over again.
I dont know the opinions of the most relevant contributors of this forum, but for sure
nobody likes to start teaching from the beginning every time a newbie post a question.
This is the reason that justify the Base Knowledge implementation.

This forum is hosted by CCS and supported by the CCS Compiler users for an open
discusion and interchange of experience of embedded C targeted to Microchip MCU´s.


Humberto
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