关于读取UART0发生地址偏移的问题。

librafox
Posts: 1
Joined: Tue Jun 26, 2018 8:39 pm

关于读取UART0发生地址偏移的问题。

Postby librafox » Tue Jun 26, 2018 9:12 pm

所用源码为ESP8266_RTOS_SDK-2.0.0。
读取Uart0寄存器代码部分:

Code: Select all

fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT;
while (pack_num < fifo_len) {
            read_package[pack_num] = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;
                 pack_num++;
          }

下位机向Uart0发送数据,数据为16进制,长度为10,数据字段为:
ff ff 00 0a 04 03 01 01 01 00

UART0第一次接收数据:
ff ff 00 0a 04 03 01 01 01 00
第二次接收数据:
00 00 00 00 00 00 00 00 00 00 ff ff 00 0a 04 03 01 01 01 00

下位机停止发送,fifo_len = 10,依然判断出有数据,数据为:
00 00 00 00 00 00 00 00 00 00

第三次接收数据:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff 00 0a 04 03 01 01 01 00

之后下位机停止发送,fifo_len = 10,依然判断出有数据,数据为:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

****数据填充位数与要接收的位数相同

Who is online

Users browsing this forum: No registered users and 7 guests