Hi.I am newbie in nxp microcontrollers.I want to send and receive data between my PC and mimxrt1020-evk with lpuart.
/*
* Copyright 2016-2023 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file MIMXRT1021_Project_uart_putty.c
* @brief Application entry point.
*/
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MIMXRT1021.h"
#include "fsl_debug_console.h"
#include "fsl_common.h"
#include "board.h"
#include "fsl_lpuart.h"
/* TODO: insert other include files here. */
/* TODO: insert other definitions and declarations here. */
/*
* @brief Application entry point.
*/
// LPUART modülü ve yapılandırma
lpuart_config_t config;
LPUART_Type *base = LPUART1;
// Veri gönderilecek tampon
uint8_t txData[] = "Hello, PC! This is LPUART1\r\n";
int main(void) {
/* Init board hardware. */
BOARD_ConfigMPU();
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
// LPUART yapılandırma
LPUART_GetDefaultConfig(&config);
config.baudRate_Bps = 115200;
// LPUART başlatma
LPUART_Init(base, &config, CLOCK_GetFreq(kCLOCK_OscClk));
/* Force the counter to be placed into memory. */
/* Enter an infinite loop, just incrementing a counter. */
while(1) {
// Veriyi gönder
LPUART_WriteBlocking(base, txData, sizeof(txData) - 1);
}
return 0 ;
}
Hi @atk05,
I highly recommend you to look into the example codes "lpuart_interrupt" from the RT1020 SDK. This example code shows everything you require to adequately enable the LPUART module on the RT, and you can base your code on this. If you have the SDK installed, just click on "Import SDK example(s)..." on the Quickstart Panel on the bottom left of the IDE.
Let me know if you have further questions.
BR,
Edwin.