Where do I read data from UART?

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 16:44:38

问题


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.


回答1:


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);


来源:https://stackoverflow.com/questions/62683711/where-do-i-read-data-from-uart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!