Hi there,
I want to using uart sends character to the pc as following
/***************************************************************************
* Defines
**************************************************************************/
#define DEMO_UART UART1
#define BOARD_DEBUG_UART_BAUDRATE 115200
/***************************************************************************
* Variables
**************************************************************************/
uint8_t txbuff[] = "Uart polling example\r\nBoard will send back received characters\r\n";
uint8_t rxbuff[20] = {0};
/***************************************************************************
* Code
**************************************************************************/
int main(void){
uint8_t ch;
uart_config_t config;
/* Init board hardware*/
BOARD_InitPins();
BOARD_BootClockRUN();
/*
* config.baudRate_Bps = 115200U;
* config.parityMode = kUART_ParityDisabled;
* config.stopBitCount = kUART_OneStopBit;
* config.txFifoWatermark = 0;
* config.rxFifoWatermark = 1;
*/
UART_Init(DEMO_UART, &config, CLOCK_GetFreq(kCLOCK_CoreSysClk));
UART_WriteBlocking(DEMO_UART, txbuff, sizeof(txbuff) - 1);
while(1)
{
UART_ReadBlocking(DEMO_UART, &ch, 1);
UART_WriteBlocking(DEMO_UART, &ch, 1);
}
}
void BOARD_InitPins(void){
CLOCK_EnableClock(kCLOCK_PortA);
CLOCK_EnableClock(kCLOCK_PortB);
CLOCK_EnableClock(kCLOCK_PortC);
CLOCK_EnableClock(kCLOCK_PortD);
CLOCK_EnableClock(kCLOCK_PortE);
PORT_SetPinMux(PORTC, 3U, kPORT_MuxAlt3);
PORT_SetPinMux(PORTC, 4U, kPORT_MuxAlt3);
}
kCLOCK_CoreSysClk @40MHz
kCLOCK_BusClk @40MHz
FEE mode
void UART_GetDefaultConfig(uart_config_t *config)
{
assert(config);
config -> baudRate_Bps = 115200U;
config -> parityMode = kUART_ParityDisabled;
#if defined(FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT
config -> stopBitCount = kUART_OneStopBit;
#endif
#if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO
config -> txFifoWatermark = 0;
config -> rxFifoWatermark = 1;
#endif
config -> enableTx = false;
config -> enableRx = false;
}
but when using FRDM-K22F runs uart_polling_transfer.c but SYSTEM_CLOCK @40MHz, BUS_CLOCK @40MHz, also in FEE mode, it runs good.
How can i fix the problem, the mk02 also can output the right message?
Thanks in advance!
-Jack
Hi Jack Xu
I see that you have the same question in the following thread: https://community.nxp.com/message/831401 , and they are already answering you, please continue with it.
Regards
Jorge Alcala
Hi Jorge,
But do not fix the problem, also three days past, there is no response.
Regards
-Jack
Hi Jack Xu
I saw in the other thread that they asked you for some information, you didn't tell them what value you have in your Baudrate. You put the code that calculate the baudrate, but the actually value depends in srcClock_Hz. So a way to completely verify this value is if you debug your code to the point where it calculate the baudrate and write the UARTx_BDH and UARTx_BDL values.
Regards
Jorge Alcala