serial uart tutorial..

Thread Starter

ect_09

Joined May 6, 2012
180
hello.,
i need tutorial for Serial UART using interrupt and C18 Compiler.
please provide me link to understand this..

Thanks..
 

Papabravo

Joined Feb 24, 2006
21,228
hello.,
i need tutorial for Serial UART using interrupt and C18 Compiler.
please provide me link to understand this..
...
i tried but didnt get suitable tutorial..
thats why i posted here...
The compiler really has nothing to do with learning about a UART. You need to start with the datasheet and look for information on the basic underlying process, which is serial to parallel conversion on receiving, and parallel to serial conversion on transmit. Wikipedia is getting better and better at providing useful information and links.

http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

Read the article, follow the links, and then come back with questions.

Check out the "UART Tutorial for Robotics" in the External Links section of the wiki article.

Remember "Google" and "Wiki" are your friends -- use them

http://lmgtfy.com/?q=UART
 
Last edited:

MrChips

Joined Oct 2, 2009
30,824
Another way of putting it is:

With the advent of the internet all the information you need is out there at your finger tips.
Go and read up on the information. Then if there is something you do not understand come back and ask questions. Don't expect others to do the search for you.
 

Thread Starter

ect_09

Joined May 6, 2012
180
it was helpful...but the its application is not clear that where we use this in real time applications.

for transmit and receiving data ,we have to write code separately for tranmitter and receiver..???

is it possible to see simulation on proteus for this , after writing code.?
 

t06afre

Joined May 11, 2009
5,934
it was helpful...but the its application is not clear that where we use this in real time applications.

for transmit and receiving data ,we have to write code separately for tranmitter and receiver..???

is it possible to see simulation on proteus for this , after writing code.?
As long as your chip is supported by your proteus version. You can do simulation. You can also cover a lot of debugging using the MPLAB software simulator. The C18 compiler is kind of outdated. It is better to use the XC8 compiler. If you will be using a free version anyway. To me it looks like you want to do a lot without accepting a to have a learning curve. It is better to start simple like not using interrupt in the beginning.
 

Thread Starter

ect_09

Joined May 6, 2012
180
yes sir,i am using XC8.but problem is to how to think for uart and code for uart.
i read mechanism that what actually is be done by this..

but problem is to program.
give tricks to think good and quick..
 

MrChips

Joined Oct 2, 2009
30,824
Writing code for UART is straight forward. Learn to do this yourself. Don't rely on someone else's code to do this. Read the manual.

Transmitter code:

wait until transmitter buffer is empty
send data

Receiver code:

wait until data is received
read data
 

Papabravo

Joined Feb 24, 2006
21,228
Writing code for UART is straight forward. Learn to do this yourself. Don't rely on someone else's code to do this. Read the manual.

Transmitter code:

wait until transmitter buffer is empty
send data

Receiver code:

wait until data is received
read data
You may not be ready for this tip, but you should know and understand the operation of a FIFO (First In First Out) buffer. For a serial UART they are often implemented in the form of a circular buffer.

Here let me google those for you!!
http://lmgtfy.com/?q=FIFO
http://lmgtfy.com/?q=Circular+Buffer
 

Thread Starter

ect_09

Joined May 6, 2012
180
Rich (BB code):
#include <P18F458.h>
void SerTx(unsigned char);
void main(void)
  {
    TXSTA=0x20;			
    SPBRG=15;			
    TXSTAbits.TXEN=1;
    RCSTAbits.SPEN=1; 
    while(1)
      {
        SerTx('Y');
        SerTx('E');
        SerTx('S');
      }
  }
void SerTx(unsigned char c)
  {  	
    while(PIR1bits.TXIF==0);	
    TXREG=c;				
  }
i see this sample code on mazidi book.
what its doing.???

Rich (BB code):
TXSTAbits.TXEN=1;
    RCSTAbits.SPEN=1;
just use TX and SPEN,is it possible that this code will work to transmit and receive.

and also tell me how much important to config PIC.??
 

t06afre

Joined May 11, 2009
5,934
Rich (BB code):
and also tell me how much important to config PIC.??
Rich (BB code):
 Because if you do not set the configuration words correct(according to your hardware config) it will not work. I have not been much active in this forum the past 10 days. So I just wonder. Have you done some simple "hello world" programming like turning a port connected to a LED on, and then get the LED to blink
 

Thread Starter

ect_09

Joined May 6, 2012
180
t06afre , i have done that with XC8 and Hitech compiler with different delays using tmr0 and _delay_ms()...

uart is 2nd topic that i want to learn after blinking LED,it will include interrupt also.

can anyone tell me how to simulate this on proteus to check my codes simulations which will be the basic understanding..

ect_09.....!!
 

sairfan1

Joined May 24, 2012
103
looks like you are here with very basic knowledge, it would be very hard for forums guys to understand and help you. I would strongly recommend, do some more work, LED blinking is quite basic thing to go further to UART, i would strongly recommend you, first learn Timers, learn its registers, how they work, initialize them in a different way, then apply interrupt on it, to learn all this get help from datasheet of MCU you are using for your project and some book, this will greatly help you to come up with valid questions and will also improve self understanding
 
Top