Single-wire UART on KL26Z ???

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Single-wire UART on KL26Z ???

1,249 Views
geoffs
Contributor I

I'm trying to use single-wire half-duplex UART mode on a FRDM-KL26Z board.  The KL16Z reference manual indicates there are a few relevant fields in the UART control register 1 to enable this functionality:

LOOPS Loop Mode Select
Selects between loop back modes and normal 2-pin full-duplex modes. When LOOPS is set, the transmitter output is internally connected to the receiver input.
0 = Normal operation - UART_RX and UART_TX use separate pins.
1 = Loop mode or single-wire mode where transmitter outputs are internally connected to receiver input. (See RSRC bit.) UART_RX pin is not used by UART.

RSRC Receiver Source Select
This bit has no meaning or effect unless the LOOPS bit is set to 1. When LOOPS is set, the receiver input is internally connected to the UART_TX pin and RSRC determines whether this connection is also
connected to the transmitter output.
0 = Provided LOOPS is set, RSRC is cleared, selects internal loop back mode and the UART does not use the UART_RX pins.
1 = Single-wire UART mode where the UART_TX pin is connected to the transmitter output and receiver input.

I'd like to use a single-wire on the TxD pin for both sending and receiving data.  I think this corresponds to LOOPS = 1 and RSRC = 1.

In Processor Expert, I've added a Serial_LDD from the component library to my project.  The only setting which I can see which relates to single-wire mode is "Loop mode" which has four options:

  • Normal
  • Automatic Echo
  • Local loop-back
  • Remote loop-back

Out of these, only Normal and Local Loop-back are available.  If I try to select the other two, PE reports that "The device doesn't support the selected loop mode".

It's not really clear how these Loop Mode options relate to the register settings.  Is "Normal" equivalent to LOOPS = 0 and RSRC = 0, with Local Loop-back equivalent to LOOPS = 1 and RSRC = 0 ?

If so, is there a way (other than writing to registers directly and not using PE) to enable LOOPS = 1 and RSRC = 1 ???

0 Kudos
Reply
1 Reply

805 Views
marek_neuzil
NXP Employee
NXP Employee

Hello Geoff,

The Serial_LDD component does not support the single wire mode now. You can use the SetLoopMode PDD macro that implements the  UART0_PDD_LOOP_MODE_RX_TO_TX_PIN loop mode value (single wire operation). See for example the code of UART0_PDD.h below:

. . .

/* Loop mode */
#define UART0_PDD_LOOP_MODE_NORMAL       0U      /**< Normal operation mode. No loopback selected. */
#define UART0_PDD_LOOP_MODE_LOCAL_LOOP   0x1U    /**< Local loopback mode. */
#define UART0_PDD_LOOP_MODE_RX_TO_TX_PIN 0x2U    /**< Receiver input connected to TXD pin (single wire operation) */

. . .

/* ----------------------------------------------------------------------------
   -- SetLoopMode
   ---------------------------------------------------------------------------- */

/**
* @brief Selects the loop mode operation.
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
*        base address). You can use the constant defined in the registers
*        definition header file (<peripheral>_BASE_PTR) or the constant defined in
*        the peripheral initialization component header file
*        (<component_name>_DEVICE).
* @param LoopMode Loop mode. This parameter is of "Loop mode" type.
* @return Returns a value of void type.
* @remarks The macro accesses the following registers: UART0_C1.
* @par Example:
*      @code
*      UART0_PDD_SetLoopMode(<peripheral>_BASE_PTR,
*      UART0_PDD_LOOP_MODE_NORMAL);
*      @endcode
*/
#define UART0_PDD_SetLoopMode(PeripheralBase, LoopMode) ( \
    ((LoopMode) == UART0_PDD_LOOP_MODE_NORMAL) ? ( \
      UART0_C1_REG(PeripheralBase) &= \
       (uint8_t)(( \
        (uint8_t)(~(uint8_t)UART0_C1_LOOPS_MASK)) & ( \
        (uint8_t)(~(uint8_t)UART0_C1_RSRC_MASK)))) : (((LoopMode) == UART0_PDD_LOOP_MODE_LOCAL_LOOP) ? ( \
      UART0_C1_REG(PeripheralBase) = \
       (uint8_t)(( \
        (uint8_t)(UART0_C1_REG(PeripheralBase) | UART0_C1_LOOPS_MASK)) & ( \
        (uint8_t)(~(uint8_t)UART0_C1_RSRC_MASK)))) : ( \
      UART0_C1_REG(PeripheralBase) |= \
       (uint8_t)(UART0_C1_LOOPS_MASK | UART0_C1_RSRC_MASK)) \
    ) \
  )

Best Regards,

Marek Neuzil

0 Kudos
Reply