serial uart tutorial..

Discussion in 'Embedded Systems and Microcontrollers' started by ect_09, May 20, 2013.

  1. ect_09

    Thread Starter Member

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

    Thanks..
     
  2. nerdegutta

    Moderator

    Dec 15, 2009
    2,517
    785
    Check this link.
     
  3. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    i tried but didnt get suitable tutorial..
    thats why i posted here...
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,793
    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: May 20, 2013
    ect_09 likes this.
  5. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,363
    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.
     
  6. Brownout

    Well-Known Member

    Jan 10, 2012
    2,375
    998
  7. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    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.?
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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.
     
  9. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    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..
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,363
    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
     
    ect_09 likes this.
  11. Papabravo

    Expert

    Feb 24, 2006
    10,152
    1,793
    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
     
  12. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    Code ( (Unknown Language)):
    1. #include <P18F458.h>
    2. void SerTx(unsigned char);
    3. void main(void)
    4.   {
    5.     TXSTA=0x20;        
    6.     SPBRG=15;          
    7.     TXSTAbits.TXEN=1;
    8.     RCSTAbits.SPEN=1;
    9.     while(1)
    10.       {
    11.         SerTx('Y');
    12.         SerTx('E');
    13.         SerTx('S');
    14.       }
    15.   }
    16. void SerTx(unsigned char c)
    17.   {    
    18.     while(PIR1bits.TXIF==0);   
    19.     TXREG=c;               
    20.   }
    21.  
    i see this sample code on mazidi book.
    what its doing.???

    Code ( (Unknown Language)):
    1.  
    2. TXSTAbits.TXEN=1;
    3.     RCSTAbits.SPEN=1;
    4.  
    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.??
     
  13. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Code ( (Unknown Language)):
    1.  
    2.  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
     
  14. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,363
    Geez. Have you opened the manual yet?
     
  15. Brownout

    Well-Known Member

    Jan 10, 2012
    2,375
    998
  16. ect_09

    Thread Starter Member

    May 6, 2012
    180
    1
    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.....!!
     
  17. sairfan1

    Member

    May 24, 2012
    46
    1
    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
     
Loading...