我在哪里从 UART 读取数据? [英] Where do I read data from UART?

查看:25
本文介绍了我在哪里从 UART 读取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 EFM32LG 控制器中,我从端口 C 引脚 1 接收 UART 数据,如下表所示,该数据取自 EFM32LG 数据表.我想读取整个字节并根据接收到的字节决定要闪烁的 LED.

在哪里可以看到整个接收到的字节?

数据表可在

解决方案

您可以从 USARTn_RXDATA 寄存器中读取接收数据的第一个字节.从本 参考手册.您还可以从 Silabs 入门指南.

我不熟悉 EFM32,但从数据表来看,它看起来像这样:

uint8_t read_byte = USART0->RXDATA;

首先通过设置 RXEN 位来启用 USART 接收器很重要.

USART0->CMD = USART0->CMD |(1<<RXEN);

In my EFM32LG controller I receive UART data from PORT C pin 1 as shown in the table below, which is taken from EFM32LG data sheet. I would like to read the whole byte and decide what LED to blink depending on the received byte.

Where can I see the whole received byte?

The data sheet is available here.

解决方案

You can read the first byte of the received data from from the USARTn_RXDATA register. The registers and functionality of the USART unit are described starting on page 447 of this reference manual. You can also learn more about programming the EFM32 from the Silabs getting started guide.

I am not familiar with the EFM32, but from the datasheet it would look something like this:

uint8_t read_byte = USART0->RXDATA;

It is important that you enable the USART receiver first by setting the RXEN bit.

USART0->CMD = USART0->CMD | (1 << RXEN);

这篇关于我在哪里从 UART 读取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆