Regarding UART4 issue in MK64FN1M0VLL12_100-LQFP_Microcontroller_NXP_Semiconductor

cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding UART4 issue in MK64FN1M0VLL12_100-LQFP_Microcontroller_NXP_Semiconductor

303 Views
chandan_kumar
Contributor I

I an facing problem with the working of UART4. UART1 is working fine but UART4 is working half the baud rate with the same configuration as UART1. Can anyone help me  why this is happening  or solution to correct it? Below is the configuration setting written in code for UART1 and UART4.

/* UART1 configuration*/

void config_UART1(void)

{

  uart_config_t config1;

  UART_GetDefaultConfig(&config1);

  config1.baudRate_Bps = UART1_BAUDRATE;    //baud rate=115200

  config1.enableTx = true;

  config1.enableRx = true;

  UART_Init(UART_1, &config1,  CLOCK_GetFreq(UART1_CLKSRC));

    UART_TransferCreateHandle(UART_1, &uart1Handle, UART1_UserCallback, NULL);

  /* Enable RX interrupt. */

  UART_EnableInterrupts(UART_1, kUART_RxDataRegFullInterruptEnable | kUART_RxOverrunInterruptEnable);

  EnableIRQ(UART1_IRQn);

}

void UART1_IRQHandler(void)

{

  uint8_t data1;

  /* If new data arrived. */

if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(UART_1))

   {

  data1 = UART_ReadByte(UART_1);

  /* If Uart1_Buffer is not full, add data to Uart1_Buffer */

      if (((rxIndex1 + 1) % Uart1_BUFFER_SIZE) != txIndex1)

   {

    Uart1_Buffer[rxIndex1] = data1;

       UART_WriteByte(UART_1, Uart1_Buffer[rxIndex1]);

     rxIndex1++;

       rxIndex1 %= Uart1_BUFFER_SIZE;

     }

   }

}

/************************************************************************************************************************/

/*UART4 Configuration*/

void config_UART4(void)

{

  uart_config_t config4;

  UART_GetDefaultConfig(&config4);

  config4.baudRate_Bps = UART4_BAUDRATE; Baud rate=115200

  config4.enableTx = true;

  config4.enableRx = true;

  UART_Init(UART_4, &config4, CLOCK_GetFreq(UART4_CLKSRC));

  UART_TransferCreateHandle(UART_4, &uart4Handle, UART4_UserCallback, NULL);

  /* Enable RX interrupt. */

  UART_EnableInterrupts(UART_4, kUART_RxDataRegFullInterruptEnable | kUART_RxOverrunInterruptEnable);

  EnableIRQ(UART4_IRQn);

}

void UART4_IRQHandler(void)

{

  uint8_t data4;

/* If new data arrived. */

  if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(UART_4))

   {

   data4 = UART_ReadByte(UART_4);

   /* If Uart4_Buffer is not full, add data to Uart4_Buffer. */

   if (((rxIndex4 + 1) % Uart4_BUFFER_SIZE) != txIndex4)

  {

       Uart4_Buffer[rxIndex4] = data4;

     UART_WriteByte(UART_4, Uart4_Buffer[rxIndex4]);

     rxIndex4++;

     rxIndex4 %= Uart4_BUFFER_SIZE;

    }

  }

}

Labels (1)
0 Kudos
1 Reply

97 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi chandan,

UART0 and UART1 modules operate from the core/system clock, which provides higher performance level for these modules. All other UART modules operate from the bus clock.

Module clocks.png

Please check the value of SIM_CLKDIV1[OUTDIV1] and SIM_CLKDIV1[OUTDIV2]. If you don't want to change the frequency of core/system clock and bus clock, then you can't use the same configuration settings.

Clocking diagram.png

Best Regards,

Robin

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos