AnsweredAssumed Answered

UART1 transmit on both TX and RX?! help on setup RX correctly

Question asked by Pablo Socolovsky on Jun 26, 2017
Latest reply on Jun 27, 2017 by Pablo Socolovsky

Hello,

 

I am using iMX6Q UART with a RTOS. I started to notice a problem on the RX line and after some investigation I built a test code to be loaded with the JTAG or USB.

The test code initializes the UART1 at pin SD3_DATA6 (E13) as ALT1 and pin SD3_DATA7 (F13) as ALT1

When I transmit some data I can see the electrical signal in the RX pin like the TX and RX line were connected together in a short circuit. I removed the HW peripheral circuit so my reading is at the pad level without anything connected, not even pull-ups or protection diodes. The TX and RX pins are not shorted together, when device is powered off I measure >10Mohms.

 

Originally the defect when connected to a peripheral was showing collision (I mean the signal is visibly corrupted) on RX pin only, but not on TX pin, so the pin is driven separately by iMX6 on both pins.

I decided to change the RX configuration to GPIO (ALT5) and I still see the signal . So at this point I thought the iMX6 could be damaged and I tried the test on another devices, all of them have the same problem even devices never powered up before and that were never running defective software drivers that could have damaged the HW.

At this point I tried to play a bit with the UART1 and IOMUX. I read the manual and checked all the bits, especially the DTE / DCE modes and loopback modes, but I couldn't make the RX pin to work as input only. I checked on internet and errata sheets and I got no matching problems.

 

Since it looks like I am the only one having this problem I decided I need help as I am definitely missing something.

 

Here is the code:

it requires regsiomuxc.h regsccm.h regsgpio.h from the SDK

 

#include <stdint.h>
#include "registers\regsiomuxc.h"
#include "registers\regsccm.h"
#include "registers/regsgpio.h"

 

#define UART1        0x02020000    

 

#define URXD    *((volatile uint32_t*)(((uint32_t)UART1) + 0x00))  // Receiver Register
#define UTXD    *((volatile uint32_t*)(((uint32_t)UART1) + 0x40)) // Transmitter Register
#define UCR1    *((volatile uint32_t*)(((uint32_t)UART1) + 0x80)) // Control Register 1
#define UCR2    *((volatile uint32_t*)(((uint32_t)UART1) + 0x84)) // Control Register 2
#define UCR3    *((volatile uint32_t*)(((uint32_t)UART1) + 0x88)) // Control Register 3
#define UCR4    *((volatile uint32_t*)(((uint32_t)UART1) + 0x8c)) // Control Register 4
#define UFCR    *((volatile uint32_t*)(((uint32_t)UART1) + 0x90)) // FIFO Control Register
#define USR1    *((volatile uint32_t*)(((uint32_t)UART1) + 0x94)) // Status Register 1
#define USR2    *((volatile uint32_t*)(((uint32_t)UART1) + 0x98)) // Status Register 2
#define UESC    *((volatile uint32_t*)(((uint32_t)UART1) + 0x9c)) // Escape Character Register
#define UTIM    *((volatile uint32_t*)(((uint32_t)UART1) + 0xa0)) // Escape Timer Register
#define UBIR    *((volatile uint32_t*)(((uint32_t)UART1) + 0xa4)) // BRM Incremental Register
#define UBMR    *((volatile uint32_t*)(((uint32_t)UART1) + 0xa8)) // BRM Modulator Register
#define UBRC    *((volatile uint32_t*)(((uint32_t)UART1) + 0xac)) // Baud Rate Count Register
#define ONEMS    *((volatile uint32_t*)(((uint32_t)UART1) + 0xb0)) // One Millisecond register
#define UTS        *((volatile uint32_t*)(((uint32_t)UART1) + 0xb4)) // UART Test Register on all other i.mx

 

void main(void)
{
    HW_CCM_CCGR0_WR(0xF0C03F0F);
    HW_CCM_CCGR1_WR(0xF0FC0C00);
    HW_CCM_CCGR2_WR(0xFC3FF00C);
    HW_CCM_CCGR3_WR(0x3FF00000);
    HW_CCM_CCGR4_WR(0x0000FF00);
    HW_CCM_CCGR5_WR(0xF0033F0F | 0x0F000000   );
    HW_CCM_CCGR6_WR(0xFFFF0303);

 

    UCR1 = 0x00000000;    // power off UART
    
    
    // Config pad SD3_DATA6(E13)
    HW_IOMUXC_SW_MUX_CTL_PAD_SD3_DATA6_WR(
            BF_IOMUXC_SW_MUX_CTL_PAD_SD3_DATA6_SION_V(DISABLED) |    //tried both enabled disable, it does not change
            BF_IOMUXC_SW_MUX_CTL_PAD_SD3_DATA6_MUX_MODE_V(ALT1));   //if I set to ALT5-input the RX is still being driven by TX driver
    HW_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA6_SRE_V(SLOW));

 

    // Config pad SD3_DATA7(F13)
    HW_IOMUXC_SW_MUX_CTL_PAD_SD3_DATA7_WR(
            BF_IOMUXC_SW_MUX_CTL_PAD_SD3_DATA7_SION_V(DISABLED) |
            BF_IOMUXC_SW_MUX_CTL_PAD_SD3_DATA7_MUX_MODE_V(ALT1));
    HW_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_SD3_DATA7_SRE_V(SLOW));
    HW_IOMUXC_UART1_UART_RX_DATA_SELECT_INPUT_WR(
            BF_IOMUXC_UART1_UART_RX_DATA_SELECT_INPUT_DAISY_V(SD3_DATA6_ALT1)); // tried to change this bit in many ways, but still no luck

   

// tried to play with uart registers, everything looks right to me

    UCR2 = 0x00004027;
    UCR3 = 0x00000784;
    UCR4 = 0x00008000;
    UESC = 0x0000002B;
    UTIM = 0x00000000;
    UTS  = 0x00000000;
    UFCR = 0x00000001  | (4<<7);
    UBIR  = 12 - 1;
    UBMR = 625 - 1;
    ONEMS = 16000000/(2 * 1000);
    UCR1 = 0x00000001;

 

    for(;;)
    {
        while (UTS & (1<<4)); UTXD = (0x5A);   // here i see the same signal on both TX and RX
    }
        
}

 

Thank you for your help and suggestions!

Outcomes