Simplicity Studio Uart Example -
// Interrupt handler for receiving data void USART0_RX_IRQHandler(void) if (USART_IntGet(UART_HANDLE) & USART_IF_RXDATAV) rx_byte = USART_Rx(UART_HANDLE); // Echo the character back USART_Tx(UART_HANDLE, rx_byte);
// Buffers char tx_buffer[64]; char rx_byte;
// Default USART configuration structure USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT; init.baudrate = 115200; init.databits = usartDatabits8; init.parity = usartNoParity; init.stopbits = usartStopbits1; simplicity studio uart example
// Initialize UART uart_init();
while (1) // Main loop does nothing – everything is interrupt driven __WFI(); // Wait for interrupt // Echo the character back USART_Tx(UART_HANDLE
// Function to initialize UART void uart_init(void) // Enable clock for USART CMU_ClockEnable(UART_CLOCK, true);
// Enable RX interrupt (optional but useful) USART_IntEnable(UART_HANDLE, USART_IEN_RXDATAV); NVIC_EnableIRQ(USART0_RX_IRQn); // Buffers char tx_buffer[64]
Create a new file main.c and add the following code:
Universal Asynchronous Receiver-Transmitter (UART) is one of the most fundamental and widely used interfaces in embedded systems. Whether you are debugging via logs, communicating with a sensor, or interfacing with a GSM module, UART is often the go-to protocol.
Introduction
int main(void) // Chip initialization (important for errata) CHIP_Init();