+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Full Member level 2
    Points: 981, Level: 7
    Achievements:
    Created Album pictures
    TiagoRibeiro's Avatar
    Join Date
    Oct 2013
    Location
    São Paulo/Brazil
    Posts
    130
    Helped
    18 / 18
    Points
    981
    Level
    7

    Serial Communication without UART

    Hello,
    I need start a project with pic18f4680, but he has only one USART. So my doubt is ... I can establish serial communication with other peripherals without using any function of the embedded pic as USART, SPI or I ² C?
    How i can do this using C?

    Thanks and waiting for the answer.

  2. #2
    Advanced Member level 5
    Points: 23,307, Level: 37
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    4,465
    Helped
    986 / 986
    Points
    23,307
    Level
    37

    Re: Serial Communication without UART

    You can write your own UART code. There's plenty of information on the web for the appropriate algorithms; there might even be some C-code out there. For the receive channel for example, you basically need to look for a start bit, read in 8 data bits, and then look for a stop bit. Easy-peazy.

    But if you're using SPI or I2C, you can have multiple slaves on one bus, you don't need a separate UART for each device.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Full Member level 2
    Points: 981, Level: 7
    Achievements:
    Created Album pictures
    TiagoRibeiro's Avatar
    Join Date
    Oct 2013
    Location
    São Paulo/Brazil
    Posts
    130
    Helped
    18 / 18
    Points
    981
    Level
    7

    Re: Serial Communication without UART

    Thank you Barry, hear this is very good.. i will search in the web sample codes to do this in C



    •   AltAdvertisement

        
       

  4. #4
    Full Member level 2
    Points: 981, Level: 7
    Achievements:
    Created Album pictures
    TiagoRibeiro's Avatar
    Join Date
    Oct 2013
    Location
    São Paulo/Brazil
    Posts
    130
    Helped
    18 / 18
    Points
    981
    Level
    7

    Re: Serial Communication without UART

    sorry but i dont find anything in the web....please show me some code sample or give links to see how do that...
    thanks



    •   AltAdvertisement

        
       

  5. #5
    Advanced Member level 5
    Points: 23,307, Level: 37
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    4,465
    Helped
    986 / 986
    Points
    23,307
    Level
    37

    Re: Serial Communication without UART

    Quote Originally Posted by TiagoRibeiro View Post
    sorry but i dont find anything in the web....please show me some code sample or give links to see how do that...
    thanks
    I don't know how you search the web, but it took me 10 seconds to find these. Did actually search "UART C-code" ????


    http://www.pjrc.com/teensy/uart.html
    http://ww1.microchip.com/downloads/e...ntc.readme.pdf
    http://www.atmel.com/images/doc4346.pdf



  6. #6
    Administrator
    Points: 69,512, Level: 64
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    bigdogguru's Avatar
    Join Date
    Mar 2010
    Location
    Southwest, USA
    Posts
    9,832
    Helped
    2357 / 2357
    Points
    69,512
    Level
    64
    Blog Entries
    4

    Re: Serial Communication without UART

    You also might find searching for "bitbang UART", "softUART" or "software UART" helpful.

    Example: Generic Software Uart written in C


    BigDog
    The Edge... there is no honest way to explain it, because the only people who really know where it is are the ones who have gone over.
    -- Hunter S. Thompson


    1 members found this post helpful.

  7. #7
    Full Member level 2
    Points: 981, Level: 7
    Achievements:
    Created Album pictures
    TiagoRibeiro's Avatar
    Join Date
    Oct 2013
    Location
    São Paulo/Brazil
    Posts
    130
    Helped
    18 / 18
    Points
    981
    Level
    7

    Re: Serial Communication without UART

    thank you Bigdog,
    This was the information I was looking for ..
    I did not know find what I needed, now with your help it is possible
    thanks again



  8. #8
    Member level 1
    Points: 1,122, Level: 7

    Join Date
    Mar 2012
    Posts
    38
    Helped
    3 / 3
    Points
    1,122
    Level
    7

    Re: Serial Communication without UART

    Yes, you can always do bit banging on the UART. I prefer writing such 'time-critical' routines in assembler though. Here are some good examples.

    http://www.piclist.com/techref/microchip/rs232.htm

    Regards



    •   AltAdvertisement

        
       

  9. #9
    Full Member level 2
    Points: 981, Level: 7
    Achievements:
    Created Album pictures
    TiagoRibeiro's Avatar
    Join Date
    Oct 2013
    Location
    São Paulo/Brazil
    Posts
    130
    Helped
    18 / 18
    Points
    981
    Level
    7

    Re: Serial Communication without UART

    hello. I managed to make my software UART send a string.
    But now I am unable to set the baud rate.
    I searched for it and found many examples in asm ( delay functions TXbit, RXbit, Halfbit),
    but I'm new in C language and is the only one I know, so I could not understand very well.
    My doubt is I have to create routines for reading and writing bit by bit?
    Can someone explain to me how to do this?
    Last edited by TiagoRibeiro; 27th January 2014 at 12:53.



  10. #10
    Advanced Member level 5
    Points: 23,307, Level: 37
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    4,465
    Helped
    986 / 986
    Points
    23,307
    Level
    37

    Re: Serial Communication without UART

    The baud rate is simply controlled by how fast you toggle your bits. A simple timer (or timer routine) can take care of that.



--[[ ]]--