UART1 configuration on FRDM board(MKL25Z4)

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

UART1 configuration on FRDM board(MKL25Z4)

660 Views
suma_success
Contributor II

Hello ,

I have configured the UART1 on FRDM board to transmit string"Hello" to Teraterm using Keil. However , the program does not work. Could you guide me on the clock source selection for UART1?

#include "MKL25Z4.h"
#include "string.h"

char data[]="hello";
int i;

int main(void)
{
SIM_SCGC4 |= SIM_SCGC4_UART1(1);
SIM_SCGC5 |= SIM_SCGC5_PORTE(1);
SIM_SOPT2 |= SIM_SOPT2_CLKOUTSEL(2); /* use bus clock for UART Baud rate generator */
PORTE_PCR0 |= PORT_PCR_MUX(3);
PORTE_PCR1 |=PORT_PCR_MUX(3);

UART1_C1 = 0x00; /* Configure Serial Port as 8-N-1 (8 data bits, No parity and 1 stop bit) */

UART1_C2 |= UART_C2_TE(1); /*Transmit Tx Enabled */
UART1_C2 |= UART_C2_RE(1); /* Receive Rx Enabled */

//BAUD: 9600 21 000 000/(16*9600) = 0x88
UART1_BDH = UART_BDH_SBR(0x0);
UART1_BDL = UART_BDL_SBR(0x88);

//transfer data to Teraterm

while(1)
{
while((UART1_S1 & UART_S1_TDRE(1)) ==0) {}
for (i=0;i<strlen(data);i++)
{
UART1_D = data[i];
}
}
}

 

0 Kudos
Reply
4 Replies

650 Views
suma_success
Contributor II

Sorry, I use the free version of Keil for building projects on FRDM board. I have no issues with UART0. However, Iam not sure of clock source for baud rate generation for UART1 

0 Kudos
Reply

630 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Please download the SDK_2_2_0_FRDM-KL25Z from .

Then you can find the UART1 example of FRDM-KL25Z with Keil MDK(...\SDK_2_2_0_FRDM-KL25Z\boards\frdmkl25z\driver_examples\uart\polling\mdk)

Note that connect USB-TTL Serial Converter with UART1 pins:
UART1_TX   D14   J2.18
UART1_RX  D15   J2.20

0 Kudos
Reply

653 Views
ErichStyger
Specialist I

Have you tried the UART example which comes with the MCUXpresso SDK? This gives you a working starting point.

0 Kudos
Reply

640 Views
suma_success
Contributor II

Sorry ! I use the evaluation version to build programs on FRDM board. I have no problems with configuring UART0. However , the dfault system clock in the header file is 21MHz. This clock choice for baud rate generation is not working for UART1. Any help will be appreciated.

0 Kudos
Reply