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];
}
}
}