FRDM-KW019032 not sending data via UART

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

FRDM-KW019032 not sending data via UART

824 Views
brunoalmeida1
Contributor I

I'm using FRDM-KW019032 to interface it with external hardware.

Device is running LF/RF Communication KDS3 rev. 1 libraries, provided by NXP, with minor modifications. Power supply is connected in J3.16, also tested in J28, and MKW01 is not sending data via UART0 until external interference (disconnecting and reconnecting UART0's wires). After that, it works perfectly.

While UART0 is working, D17 usually emits green light. FDRM rarely sends data with D17 turned off.

No Resistor or any other component were removed or added to default board.

0 Kudos
6 Replies

573 Views
brunoalmeida1
Contributor I

Hello,

I am using the following code to initialize UART0.

#define UART_RE_SHIFT    2
#define UART_TE_SHIFT    3
#define UART0_DISABLE_RECEPTION        (UART0_C2 &= ~(1<<UART_RE_SHIFT))
#define UART0_ENABLE_RECEPTION        (UART0_C2 |= (1<<UART_RE_SHIFT))
#define UART0_DISABLE_TRANSMISSION    (UART0_C2 &= ~(1<<UART_TE_SHIFT))
#define UART0_ENABLE_TRANSMISSION    (UART0_C2 |= (1<<UART_TE_SHIFT))

void Init_UART0_General (void)
{
        uint8_t dummy;

       /* Setup Clock Source for UART 0
        * Select clock source to be MCGFLLCLK
        * (we are in FEE mode with MCGFLLCLK=20.9MHz)
        */
       SIM_SOPT2 |= (SIM_SOPT2_UART0SRC(SOPT2_UART0_MCGFLLCLK));

       /* Enable UART0 clock */
       SIM_SCGC4 |= SIM_SCGC4_UART0_MASK;

        /* Setup Port Control Register for RX pin */
       gUART0_RX_PCR_REG_c = PORT_PCR_MUX(gUART0_PORT_MUX_c);//gUART0_PORT_MUX_c);

        /* Setup Port Control Register for TX pin */
       gUART0_TX_PCR_REG_c = PORT_PCR_MUX(gUART0_PORT_MUX_c);

       //PORTA_PCR1_IRQC    page 273(142)
       PORTA_PCR1 |= (1 << 17);    // Interruption on falling edge

       /* Disable transceiver to do the configuration */
       UART0_DISABLE_RECEPTION;
       UART0_DISABLE_TRANSMISSION;

       /* Configure BDH and BDL */
       UART0_BDH = 0x00; // Keep default value for now
       UART0_BDL = 0x04; // Keep default value for now

       /* Configure C1 register */
       UART0_C1 = 0x00; // 8-bit Mode ; No parity

       /* Configure C2 register */
       UART0_C2 = 0x00; // Disable all interrupts for now

       /* Clear all flags */
      // UART0_S1 = 0x1F; // w1c
       UART0_S2 = 0x00;

       /* Configure C3 register */
       UART0_C3 = 0x00; // Keep default configuration

       /* Configure C4 register */
       UART0_C4 = 0x0F; // Disable Match Address ; OSR=16 (default)

       /* Configure C5 register */
       UART0_C5 = 0x00; // BOTHEDGE=0 as OSR=16 (BOTHEDGE must be set when 0SR is between 4 and 7


        /* Enables the interrupts corresponding to UART_0 driver */
        NVIC_EnableIRQ(UART0_IRQn);
        NVIC_SetPriority(UART0_IRQn, UART0_INTERRUPT_PRIORITY);
        NVIC_ClearPendingIRQ(UART0_IRQn);

       // Init RX interrupts
       // UART0_C3 |= UART0_C3_ORIE_MASK; // Implement later if useful
        UART0_C2 |= UART0_C2_RIE_MASK;

        /* Variable used in Rx ISR */
        UART0_RxBufferFull = 0;

        /* Read Rx buffer to clear the flags */
        dummy = UART0_D;

}

Regards,

Bruno Silva

0 Kudos

573 Views
estephania_mart
NXP TechSupport
NXP TechSupport

 Hello,

 

Could you please check the signals of RX and TX form the UART to check if the data it’s being sent correctly since the beginning?

 

Also, did you test the UART by itself? Do you have the same behavior?

 

Regards,

Estephania

0 Kudos

573 Views
brunoalmeida1
Contributor I

Hi,

Problem partially solved. Followed this discussion, disconnected J41 and J42, placed RX and TX directly there and it worked. I could not figure out why J14 had to be connected to P&E Miltilink though. When I remove It, TX starts to send noise.

Still need to solve reception problem, register is not setting no matter what.

Regards,

Bruno Silva

0 Kudos

573 Views
lisettelozano
NXP Employee
NXP Employee

Hello Bruno,

 

Are you connecting the Arduino to our FRDM board? Can you please confirm the connections that you have?

Please note that the OpenSDA sends the signals UART0_RX to Pin 2 in J41 and UART0_TX to Pin 1 in J42. Therefore, you need to connect the RX and TX directly to Pin 1 in J41 and Pin 2 in J42 respectively.

Regarding the register problem RDRF in UART0_S1, can you please confirm the connections changed?

Best regards,

Paulina

0 Kudos

573 Views
brunoalmeida1
Contributor I

Hi, Paulina. Sorry for my late reply.

Based on what you said connections were correct. RX to Pin 1 in J41 and TX to Pin 2 in J42.

Regards,

Bruno

0 Kudos

573 Views
brunoalmeida1
Contributor I

I could only check signals sent via TX and it is correct. Since I am using an Arduino to send data at specific baud rate to RX pin, I assume It's also correct.

I tested UART0 in two FDRM boards and they're showing the same problem. After reconnecting wires (and green LED turning on), data is tranferred without problems via UART0_TX.

Also, I'm having issues with reception register (RDRF in UART0_S1) after changing connections and sending correctly via TX. The register is not pulling-up even with RIE and RE sets in UART0_C2 using "LF/RF Communication KDS3 rev. 1" UART library.

0 Kudos