• AVR Freaks

EZBL half-duplex UART over single wire

Author
Severino
New Member
  • Total Posts : 23
  • Reward points : 0
  • Joined: 2014/04/30 01:50:28
  • Location: 0
  • Status: offline
2019/11/08 02:02:36 (permalink)
0

EZBL half-duplex UART over single wire

I need to implement a boot loading procedure using an UART that works over in half-duplex over a single wire (plus GND).
The TX are connected in such way as to avoid a short. (e.g. with an open collector transistor with pull-up resistor).

I found helpful hints regarding how to avoid simultaneous transmission and reception in:
https://www.microchip.com/forums/FindPost/1065206

But different from RS-485, I don't have a hardware driver that can disable reception during transmission as in the RS-485 transceivers like MAX485 etc.

The problem is that every side (boot loader and ezbl_comm.exe) receives an echo of what it sends. I therefore need to either suppress reception during transmission, or to discard the received bytes after transmission.

I'm not sure where to start looking either in the boot loader and in the ezbl_comm (temporarily disable reception, or discard rx buffer, or...?).
 
BTW: The controller is the dsPIC33EP256GP502.

Any hints would be very much appreciated. Thanks.
#1

6 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3156
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: EZBL half-duplex UART over single wire 2019/11/08 02:31:57 (permalink)
    0
    There's a multitude of options available.
    I'd suggest to check whether a sample configuration for LIN is available/documented, which has exactly the same challenge.
    (Only) If not, my personal preference would be to (dummy) read the RX register each time I TX a byte - plus one more time prior "switching" to RX. The PC side might be different, or you modify the PC's interface such that RX is disabled when transmitting. (Can be done in a number of ways.)
     

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    Severino
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: EZBL half-duplex UART over single wire 2019/11/08 05:18:04 (permalink)
    0
    Thanks du00000001 for your reply.
    I prefer sticking to the UART communication as the device anyway needs UART comms after bootloading.
    Dummy reading of the RX register is exactly what I want to do, but as EZBL is some kind of a complex thing I wonder whether it's better to do it at very low UART register level or at RX FIFO level. My hope is that somebody familiar with EZBL (Howard Schlunder?) would point me to the file/function where to do it. If possible, I would like to avoid recompiling the EZBL library.
    Regarding the Windows ezbl_comm.exe I can compile the VS2008 project. I prefer solving it in software, as many solutions applied for RS-485 are baudrate dependent.
    #3
    du00000001
    Just Some Member
    • Total Posts : 3156
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: EZBL half-duplex UART over single wire 2019/11/08 05:41:16 (permalink)
    5 (1)
    Severino
    I prefer sticking to the UART communication ...

     
    Oh - I assumed everybody knows - or might be able to acquire that little bit of information:
    LIN is UART-based and half-duplex - very similar to what you seem to have.
    The most important difference might be that LIN is - to some extend - autobaud-capable.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    Severino
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: EZBL half-duplex UART over single wire 2019/11/08 06:08:17 (permalink)
    0
    Oh - I assumed everybody knows - or might be able to acquire that little bit of information:
    LIN is UART-based and half-duplex...

    Ok, I apologize for my ignorance and for my inaccurate expression. I prefer not to implement the whole LIN protocol stack.
    To cut a long story short: As unfortunately my time budget is limited, I would like to use the boot loader in it's UART implementation as included in the EZBL package and modify it to suit my needs. The first part (making EZBL run in half-duplex) is solved thanks to the postings in the thread linked in my first post.
    I just hope to find practical tips related to the ex_boot_uart example project in the EZBL package.
    Regarding the PC side: could you please elaborate on
    The PC side might be different, or you modify the PC's interface such that RX is disabled when transmitting. (Can be done in a number of ways.)

    One way is to modify the ezbl_comm source code, another might involve a hardware interface.
    Many thanks in advance.
    post edited by Severino - 2019/11/08 06:09:38
    #5
    NorthGuy
    Super Member
    • Total Posts : 5733
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: EZBL half-duplex UART over single wire 2019/11/08 07:07:42 (permalink)
    0
    What to do with TX characters reflected back would be the least of my worries. Just read the RCREG (or whatever is the UART reading register) every time you transmit something, then one more time after transmission is complete.
     
    <edit> If your UART has buffer, you must linger after the transmit until the buffer is sent out, then read back until the receive UART buffer is empty. </edit>
     
    As to the synchronization, the best way is as in USB - the master (host) produces read slots where the slave (device) must send the data, and the slave is not allowed to transmit in other times.
     
    post edited by NorthGuy - 2019/11/08 07:23:21
    #6
    Severino
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: EZBL half-duplex UART over single wire 2019/11/08 08:04:48 (permalink)
    0
    Thanks NorthGuy.
    In fact, if you are familiar with EZBL you know that it makes use of TX and RX FIFOs, a task scheduler, and more.
    It's not a simple while(*ptr != 0) loop. Reception is made somewhere else (in it's own ISR), and I hope that some experienced EZBL users or developers would guide me.
    In the FIFO write callback function there is no reference to the RX FIFO (why should there be?). If I simply read the UxRXREG this would interfere with the RX ISR.
    Synchronization is solved as described in the link from my first post.
     
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5