Perintah Kawalan Pergerakan (PKP) hari ke-117

PIC Lesson: UART Module

UART adalah singkatan bagi Universal Asynchronous Receiver Transmitter. Address yang terlibat dalam UART Module adalah TXSTA, RCSTA dan SPBRG.

Isyarat UART menghantar dan menerima data melalui tiga wayar iaitu TX, RX dan GND. Isyarat UART terdapat dalam jenis Synchronous atau Asynchronous. Synchronous transmission memerlukan penghantar dan penerima berkongsi clock signal yang sama. Asynchronous transmission pula membolehkan data di hantar tanpa menghantar clock signal tetapi penghantar dan penerima mesti beroperasi pada timing parameter yang sama yang dikenali Baud Rate.

Setting BRGH akan menentukan Baud Rate Formula. Contohnya, dengan menggunakan crystal 20MHz, Low Speed Asynchronous boleh menghasilkan Baud Rate dari 1,221Hz-312,500Hz, High Speed Asynchronous boleh menghasilkan Baud Rate dari 4,883Hz-1,250kHz dan Synchronous boleh menghasilkan Baud Rate dari 19.53kHz-5MHz.

Antara alatan menggunakan UART adalah PS2 Controller Starter Kit ataupun SKPS daripada Cytron. Sambungan PIC dengan SKPS menggunakan pin RX dan TX.

Schematic SKPS

Caranya adalah PIC meminta ataupun request PS2 Controller status berdasarkan SKPS Protocol.

Berikut adalah videonya.

PIC Source Code

24 Replies to “PIC Lesson: UART Module”

  1. salam.
    leh tnya x bang?
    kita leh trus connect SKPS trus ke PIC ke?
    xperlu setting apa2?
    or kita kna tulis programming nye…

  2. salam bro shah

    ak nk tye skitla
    boleh ke force sensor dri cytron gune tok measure weight??

    kt mane ek nk kne ubah?

    sekian
    adios!!
    :D

  3. saya dah dapat header file untul libaryUART.h bagaimana pulak dgn souce codenye? sbb kalau tak ada pon tak boleh nak simulet pada MPLAB, dan lagy satu, kalau saya copy sahaja file tu mcm mane nak jdkan dia h file. kalau copy dalam note pad, akan jd formate notepad.

    1. ismawanieh, software MPLab x boleh simulate. Biasa saya terus testing pada hardware. File library tu, dlm MPLab buka new file, copy-paste code dan save kan dgn taipkan .h, baru tukar jadi file header.

  4. hi…thanks for the fast reply,that is the problem, I’m only limited to using two PIC16F877 only….okay, if I program uart software, how do I go about it?

  5. hi shahrul, I have a problem ….im using two pic16f877 to implement a transceiver module, however i need more than two uart as im interfacing PC with the pic using RS232..do you have any suggestions on how to share the uart? is it by multiplexing? if so how? Thanks in advance..

    1. hi zan, if you need to use two uart, you can program uart software or other choice find other PIC that have more than one uart module, normally dspic.

  6. salam….saya nak tanya..boleh tak jadi advisor saya untk wireless smoke detector system…using rf module

  7. salam. sy fauzi and final year student to-be. ur comment at cytron forum attracted me to ask u a few Q and i hope i can make u as my reference. :)

    actually sy ni mobile communication student which i lake of programming. but then, im interested with cytron’s DIY project; PR11.

    i just made simulation using proteus and its work!

    then, i would like to modified them with gsm module. which mean; whenever the temperature sensor is in high level value, i will get a notification from the GSM.

    do hav any idea in modify them both?

    tq in advance. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.