• AVR Freaks

Hot!Full Dublex Software UART Communication

Author
f3ynman
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2018/08/15 00:33:38
  • Location: 0
  • Status: offline
2018/08/17 02:03:54 (permalink)
0

Full Dublex Software UART Communication

Hello to everyone,
I writed myself a serial communication sofware and actually its working full dublex(one line for rc one line for tx) but not like microchip's tx/rc pins. Its not possible to receive and transmit at the same time. Is there any way to make parallel receive and transmit with a sofware uart ? 
I guess i should learn to live with this restriction. I just wonder if its possible.
post edited by f3ynman - 2018/08/17 02:07:57
#1

15 Replies Related Threads

    qɥb
    Monolothic Member
    • Total Posts : 3332
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 02:43:50 (permalink)
    +1 (1)
    f3ynman
    ...
    Its not possible to receive and transmit at the same time.

    It's not full duplex then.
     

    Is there any way to make parallel receive and transmit with a sofware uart ?

    Yes, but it's not easy.
    The best way is to use a timer interrupt, running at least 4x the required baud rate, and do all your bit banging in the interrupt service.

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #2
    f3ynman
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2018/08/15 00:33:38
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 02:46:32 (permalink)
    0
    That's cool. Can you give me any target to go for that ? Where should i look ?
     
    And by the way thank you for correcting my info about full dublex. I learned that way from a book. But probably i misunderstood it or maybe writer was talking about physical layer of full dublex.
    post edited by f3ynman - 2018/08/17 02:55:32
    #3
    qɥb
    Monolothic Member
    • Total Posts : 3332
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 03:06:51 (permalink)
    +1 (1)
    I guess you could try googling "bit bang full duplex serial".
    Personally, I'd just think it through, and do it from scratch.
    Transmit is easy, and could be done with an ISR just running at the exact baud rate.
    Receive is harder, and that is what requires the timer to run faster than the baud rate, so you can detect the falling edge of the start bit, and attempt to sample the data in the middle of the following bits.
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #4
    f3ynman
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2018/08/15 00:33:38
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 03:09:35 (permalink)
    0
    I writed that version by myself and i liked your suggestion i will try to write this one by myself too. Thank you for helping me. Good days.
    #5
    Chris A
    Super Member
    • Total Posts : 848
    • Reward points : 0
    • Joined: 2010/07/20 04:37:07
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 03:18:49 (permalink)
    0
    I've done it on a PIC18 using Timer0 for TX and Timer3 + CPP1 for Rx. Both using high priority interrupt.
    I had to increase clock to 32MHz (8MHz CPU) to get accurate timing at 19200baud. I've also used RBIF for the start bit instead of CPP1IF.
     
    Rx receives CCP interrupt on start bit, and sets up timer3 to interrupt after 1/2 bit to check start bit is still present, then at 1 bit intervals for each bit and stop bits.
    Tx is easier (40 lines of code).
     
    Do not attempt this unless you have a scope that can check your timing.  You can also toggle an IO line at your receive sampling point to confirm timing of receive.
     
    post edited by Chris A - 2018/08/17 03:26:27
    #6
    qɥb
    Monolothic Member
    • Total Posts : 3332
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 03:23:08 (permalink)
    0
    I found using a single timer running at 4x the baud rate avoided the hassle of multiple interrupts fighting with each other.
    Then just a simple state machine for Rx and another for Tx can do everything with precise timing.

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #7
    Chris A
    Super Member
    • Total Posts : 848
    • Reward points : 0
    • Joined: 2010/07/20 04:37:07
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/17 03:46:07 (permalink)
    0
    qɥb
    I found using a single timer running at 4x the baud rate avoided the hassle of multiple interrupts fighting with each other.

    I can see that could be good if you can get the code nice and concise. Are you Rx sampling x2 as well?
     
    In my version the effect of Tx delaying Rx or vice versa is about 20 instructions or 5% at 19200, but the timers are adjusted so it does not creep with each interrupt/bit.
     
    I don't use the CCP for each bit transition - That would be really neat but the code maybe long and also may need spike removal!
    #8
    K8LH
    Super Member
    • Total Posts : 1872
    • Reward points : 0
    • Joined: 2004/03/26 05:12:34
    • Location: Michigan, USA
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/19 21:07:58 (permalink)
    0
    If it's any help...  I posted a bit-banged full-duplex 9600 baud demo for 16F619 on PICLIST long ago.  It uses timer driven interrupts at 3x the 9600 baud rate and uses about 50% of the processing time (8-MHz clock);
     
    K8LH Bit-Banged Full-Duplex 9600 Baud Demo
     
    Cheerful regards, Mike

    ;******************************************************************
    ;* *
    ;* Filename: 16F819 Serial 1.asm *
    ;* Author: Mike McLaren, K8LH (k8lh_at_arrl.net) *
    ;* Date: 08-Jun-05 (last revision 12-Jun-05) *
    ;* *
    ;* Full Duplex Bit-Banged 9600 Baud Serial I/O Demo *
    ;* (based on a nearly identical 12F683 Demo) *
    ;* *
    ;* ·Uses 16F819 INTOSC running at 8-MHz *
    ;* ·Bit rate error 0.6% plus or minus 1.0% for INTOSC *
    ;* ·Bit-banged 9600 baud serial I/O *
    ;* ·Full Duplex (TX and RX simultaneously) *
    ;* ·Interrupts at approximately 3X bit rate every *
    ;* 34.5 usecs (every 69 instruction cycles) *
    ;* ·Circular 16-byte receive ahead buffer *
    ;* ·Circular 16-byte transmit ahead buffer *
    ;* ·Inverted TX and RX signals (MAX232A or similar *
    ;* inverting RS-232 interface required) *
    ;* ·ISR and Init232, Put232, and Get232 support routines *
    ;* fit comfortably in the first 192 words of code space *
    ;* occupying memory from 0004 through 00BF (188 words) *
    ;* *
    ;* MPLab: 7.11 (tabs=8) *
    ;* MPAsm: 4.01 *
    ;* *
    ;******************************************************************
     [/code]
    #9
    Aussie Susan
    Super Member
    • Total Posts : 3672
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/20 19:33:08 (permalink)
    0
    Is there any particular reason why you are not using a hardware UART for this?
    You will save you self a lot of trouble in the long run.
    Susan
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 18266
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2018/08/20 20:40:29 (permalink)
    0
    A bit banged UART will not work as well as a Hardware one. Especially if you need real full duplex.
    #11
    f3ynman
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2018/08/15 00:33:38
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2020/01/16 08:54:43 (permalink)
    0
    I have only one uart module on my chip
    #12
    pcbbc
    Super Member
    • Total Posts : 1507
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2020/01/16 11:02:25 (permalink)
    +2 (2)
    What happened?  Have you been receiving in half duplex yourself for 16 months?
    #13
    NKurzman
    A Guy on the Net
    • Total Posts : 18266
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2020/01/16 11:28:35 (permalink)
    0
    I just assumed its was done and shipped.
    #14
    f3ynman
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2018/08/15 00:33:38
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2020/01/16 13:44:24 (permalink)
    +1 (1)
    hahah i done what i wanted with sofware uart and it become a very messy software. It worked anyway but as kurzman say its nothing like a hardware uart.
    #15
    nigelwright7557
    Super Member
    • Total Posts : 344
    • Reward points : 0
    • Joined: 2006/11/06 08:15:51
    • Location: 0
    • Status: offline
    Re: Full Dublex Software UART Communication 2020/01/17 14:20:48 (permalink)
    0
    f3ynman
    hahah i done what i wanted with sofware uart and it become a very messy software. It worked anyway but as kurzman say its nothing like a hardware uart.


    A lot of stand alone UART's ran at x16 or x64 times clock.
     
    #16
    Jump to:
    © 2020 APG vNext Commercial Version 4.5