No announcement yet.

USART Half-duplex Control of RS485 Driver Enable Line using JSAPI

  • Filter
  • Time
  • Show
Clear All
new posts

  • USART Half-duplex Control of RS485 Driver Enable Line using JSAPI

    When we use JSAPI, we don't have access (or at least a hook into) the TX_Register_Empty interrupt for the USART.
    This makes it difficult to control the DE line effectively as I never know when the data is done sending.
    I am therefore forced to use bare metal approaches to get at this particular interrupt.

    IDEAL would be a method whereby JSAPI can be told where the DE line is connected and have it all happen by magic.
    2nd choice is to have a hook-in to a "FIFO EMPTY" event (since we have no direct control over the FIFO either)
    3rd choice is a hook-in to the TX_Register_Empty interrupt.

    Is there ANY chance of perhaps at least choice number 2? - I gather this should be quite easy as you are probably already disabling the interrupt when the FIFO runs empty?
    And perhaps failing this, if you are in fact disabling the interrupt under those circumstances, I could perhaps just poll the particular bit in the interrupt enable registers?

  • #2
    My idea of monitoring the interrupt enable bit sounded good until I got the scope out...
    It goes active AFTER the bytes start appearing on the port, and goes inactive before the last byte is out...

    Last edited by Carel is cool; 11-09-2017, 04:53 AM.


    • #3
      Another update:

      I eventually did this the dumb way by calculating how long my message would take to go out, and then set the DE line before transmission and count down in my main periodic interrupt until that much time has gone by, then clearing the DE again. This works OK, but is obviously not elegant. It forces me to find a compromise between clearing the DE soon after the transmission ends, and having my timer run at a reasonable speed. Since my baudrate is at 250k, I need my interrupt running at intervals of 100uS to get a fine enough control over it. I don't particularly like running the interrupt at such speed, being the stingy bastard that I am..


      • #4
        I will add this to the feature request list because I see value in half-duplex RS485 applications.