pic to pic communication using uart

Discussion in 'Embedded Systems and Microcontrollers' started by franklin75, Jul 2, 2016.

  1. franklin75

    Thread Starter New Member

    Jun 11, 2016
    14
    1
    Hi! i am interested in communication so in current days i am studying uart but have a some problems and questions about uart.Basicly i want to communicate with two pic using uart.Example:first pic have a button and led and second pic have a button and led,when you push the first pic's button the led blink(which is the second pic's ) and when you push the second pic's button the led blink(which is the first pic's).The project is so basicly but i want to understand this subject .please send me a some suggestions.thanks for your helps.
     
  2. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    Read the manual.
     
  3. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,548
    2,373
    I would include the Maxim Uart IC MAX-232 this way you can test your code by attaching to a COM port on a P.C. using one of the free RS232 monitor programs,
    There is a lot of info on UART control on the Picmicro site.
    And tutoriols on the Nigel goodwin site also.
    http://pic-rosa.blogspot.ca/2007/09/source-code-for-pic.html
    Max.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    UART is an acronym for Universal Asynchronous Receiver Transmitter. It is a hardware device that sends and receives characters. The characters are normally 8 bits in length and are encapsulated or "framed" by a START bit and a STOP bit. The receiver and transmitter need to have clocks that are close in frequency but do not have to be exactly the same. The characters may arrive at any time either singaly or in bursts. In order for the transmissions to be meaningful bot side must agree on what things mean. Assigning meaning to groups of characters is called "defining a protocol".

    What else would you like to know?
     
  5. dannyf

    Well-Known Member

    Sep 13, 2015
    1,811
    362
    this is kind like your i2c project in that your difficulties stem from your lack of what you are trying to do, and how the devices work (not how you think they work).

    I would say that you should read the datasheet as much as you can and then start coding a master and then a slave.
     
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,548
    2,373
  7. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,694
    904
    I echo the comments about providing more information. Serial (i.e., RS232 type) communication between PICs is quite easy.

    Do you plan to use hardware or software?
    What programming language?

    If you are open to using Assembly language for software driven communication, I can share some code that was shared with me several years ago. If you plan to use hardware, then the best resources for that are the applicable datasheets. Once you get through setting the registers, it runs smoothly. There are tables and online aids for calculating the registers to set baud rate.

    John
     
  8. m zaid

    Member

    Jan 9, 2016
    46
    5
    I agree with MaxHeadRoom. Use the PC to test your PIC sending some data first. If it isn't working later between two PICs, you will know which part is problematic, the transmitting part or the receiving part.

    When I started, there was http://www.cytron.com.my/p-uc00a?search=uart&sort=relevance&order=DESC. You'll find more information on the page too.
     
    Last edited: Jul 2, 2016
  9. NorthGuy

    Active Member

    Jun 28, 2014
    604
    121
    UART signaling between PICs is on TTL level. PC requires RS232 levels, so if you want to talk to PC you will need an RS232 converter, such as MAX232, and also COM port on the PC, or some sort of USB converter. Setting up these things is more complicated than talking between PICs on TTL level.

    Start from single PIC, connect RX and TX pins together. Now you have the PIC talking to itself - you can send something, then receive it back.

    Going to two PICs is as simple as reconnecting them with 2 wires TX-to-RX.

    It's much simpler than I2C :)
     
  10. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,548
    2,373
    Nothing complicated IMO?, it requires no extra programming and it makes debugging easier with a PC RS232 program to test.
    Max.
     
  11. franklin75

    Thread Starter New Member

    Jun 11, 2016
    14
    1
    i am using c language.can you send me a same code for i2c,uart and spi?
     
  12. franklin75

    Thread Starter New Member

    Jun 11, 2016
    14
    1
    thank you!!!
     
  13. dannyf

    Well-Known Member

    Sep 13, 2015
    1,811
    362
    I really hope that you realize that anyone doing that is hurting you. The best help you can get now is to read the datasheets and read the compiler manuals so YOU can develop good understanding of how the devices and your tools work.
     
    jpanhalt likes this.
  14. franklin75

    Thread Starter New Member

    Jun 11, 2016
    14
    1
    my englishs is very bad sometimes i do not understand you but thank you for your suggestion.
     
Loading...