Issue in UART read with DA14580

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
13个职位/0个新职位
Last post
德里希
Offline
Last seen:3年3个月前
加入:2017-02-10 09:56
Issue in UART read with DA14580

Hi,

我们的设置有一个通过UART连接到DA14580的外部MCU。DA14580与单片机之间采用我们设计的协议进行通信。
DA14580 is waiting on uart read for 5 byte header. The MCU sends the header (5 bytes) which has the data_length. DA14580 then does the uart_read with data_length bytes to be received.
Observation:
假设MCU必须发送5字节头和32字节数据。
UART硬件使用的内部缓冲区似乎是16字节。因为我们看到的是,DA14580正确地接收到报头,然后尝试在go中读取32字节,如果DA14580的UART HW缓冲区中已经存在部分数据,那么读取回调就永远不会被调用,即,32字节永远不会被完全读取。
Whereas if the uart read of 32 bytes is called before the actual data is received from the MCU the entire read is successful and the read callback gets executed correctly.

我们还尝试在读取头之后从DA14580读取一个字节。在这种情况下,所发生的是,(16-5)即11个字节被正确读取一个接一个。尽管其他字节已由MCU发送,但DA14580从未接收到它们。

似乎是DA14580 UART的问题。请您检查一下,然后回复。
没有te: We also enabled HW level flow control and are still seeing this issue. Can you please confirm if HW flow control is working fine and is turned on using the API uart_flow_on()

-赫里希克什

设备:
LC\U对话框
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-09-19 23:20
Hello Hrishikesh,

Hello Hrishikesh,

I am currently investigating this issue and will provide an update to resolve this.

Best,
LC

LC\U对话框
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-09-19 23:20
Hello Hrishikesh,

Hello Hrishikesh,

硬件FIFO为16字节,按照标准提供1、4、8和14字节的中断。您使用的当前中断级别是多少?如果当前中断级别有问题,则可以执行以下选项

Disable to FIFO and read the data normally from the receiver buffer. This can be achieved by monitoring the Rx Data Avaliable interrupt and Rx Timeout interrupt. This way you will be in control of how much data you are receving. Based on the lenght field in your header, you can read incrementing to that many bytes.

另一个选项是配置您的RTL中断,以触发FIFO中接收到的每个字节,包括接收报头(在较低的速度下工作最好(比如115200)。这样你就可以根据你的需要阅读更多的数据。

请对您的应用程序实现提供更多的见解,如当前波特率、什么是RTL中断等,以及如何读取第一个报头和下一个数据,这将有助于找出实际问题。如果你还有什么问题,请告诉我

Best,
LC

德里希
Offline
Last seen:3年3个月前
加入:2017-02-10 09:56
The uart related issue is

The uart related issue is solved. The problem was that the uart flow control was not getting enabled.

在调用uart\u init()之后,我们使用了uart\u flow\u on()API
This should be documented in the SDK header file for uart_flow_on() : This API needs to be called before uart_init() to take effect.

LC\U对话框
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-09-19 23:20
Hello drishi,

Hello dhrishi,

世界的秩序uart\u flow\u on()uart_init()启用硬件流控制应该无关紧要。可能还有其他原因。

请确认您所面临的问题是否已完全解决。

Best,
LC

德里希
Offline
Last seen:3年3个月前
加入:2017-02-10 09:56
Yes. The issue we were facing

Yes. The issue we were facing is completely resolved. Although, when I interchange the sequence of uart_flow_on() and uart_init() I could see that the flow control does not come into effect.
Anyway, I will give it a try once again and update in case of any new observations/findings.

谢谢,
瑞诗凯施

LC\U对话框
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-09-19 23:20
Hello Hrishikesh,

Hello Hrishikesh,

很高兴听到事情解决了。我会检讨它,如果它没有指定,并确保它是在相关的地方更新。

Best,
LC

kqtrinh
Offline
Last seen:3年10个月前
加入:2016-08-24 00:17
嗨,LC,

嗨,LC,

我有类似的问题,UART读取从外部MCU以及。

After reading this post, I tried per the suggestion by calling uart_flow_on() after uart_init(). That didn't help me.
What I have is a UART2 setup to communicate with an external MCU at 57.6Kbps. Sending data from DA to external MCU is fine. it was able to receive everything the DA sends. However, when receiving UART data from the external MCU back into the DA has frame error for every transaction. I have attached the Saleae capture for you to look at.

In the capture, DataToQPI is data sent from DA to external MCU while DataFromQPI is data sent from external MCU to DA.

Thank you,
--Khai

kqtrinh
Offline
Last seen:3年10个月前
加入:2016-08-24 00:17
嗨,LC,

嗨,LC,

I figured out my problem. I had to configure the RX pin as PULL_UP below:

GPIO\ U配置引脚(GPIO\ U UART2\ U RX\端口、GPIO\ U UART2\ U RX\引脚、输入\上拉、PID\ U UART2\ U RX、false);
谢谢,
--Khai

kqtrinh
Offline
Last seen:3年10个月前
加入:2016-08-24 00:17
嗨,LC,

嗨,LC,

既然RX上拉线已经被排除了,我就有一个后续问题,就是将RX线上的数据读入DA缓冲区。下面是我从UARt2读取RX数据的代码:

bool readFromCIIf(BYTE* data, int data_len) {
bool r = true;
short idx = 0;
int nbytes = 0, bytes_left = data_len;

while(idx<数据长度){
//等待1毫秒,让FPGA在CI UART数据寄存器中加载一个字节
qdispincounter(勾选1毫秒);

//找出要发送到ASIC的CI输出缓冲区的字节数
//尝试使用CI\u OUTPUT\u BUFFER\u SZ而不是RX\u CALLBACK\u SIZE
if(bytes\ u left>CI\ u OUTPUT\ u BUFFER\ u SZ)
nbytes=CI\u OUTPUT\u BUFFER\u SZ;
else
nbytes = bytes_left;

//删除将从剩余的总字节数中检索的字节数
bytes_left -= nbytes;

//从ASIC读取字节
uart2_read(data+idx, nbytes, NULL);
idx += nbytes;
}
return r;
}

I have played with both CI_OUTPUT_BUFFER_SZ = 256 bytes while RX_CALLBACK_SIZE = 8 bytes. The caller to this function requests to read 140 bytes. I have looked in the RX line with Saleae and all 140 bytes were were on the wire in the attached logicdata file. However, when the above function walked through the loop to read, the bytes read into the buffer wasn't the same as what's on the wire.

When I used RX_CALLBACK_SIZE, the first 16 bytes looked good. After that, the bytes in memory are missing and being skipped to the next several bytes. Then, the rest are then all 0s at time point. When using CI_OUTPUT_BUFFER_SZ, I would only get maybe the first 16 bytes and the rest are 0s.

Somehow specifying the read buffer size for each read seems to matter. What does this have to be to read the data correctly?

谢谢,
--Khai

Attachment:
LC\U对话框
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-09-19 23:20
你好,凯,

你好,凯,

我无法在我这边重现那个问题。所以我不太确定这个案子到底出了什么问题。不过,我想提几点建议。

1. Please check if you GPIO are assigned accordingly and the connections are right. I think they are alligned properly since you can see the data on the Logic Analyzer.

2. I am attaching a sample driver that was modified from the actual driver to address RX FIFO adjustment. Try using this driver in place of the current one and check if that solves the issue. Note that this is not a official release driver and only for testing purposes.

Best,
LC

Attachment:
kqtrinh
Offline
Last seen:3年10个月前
加入:2016-08-24 00:17
嗨,LC,

嗨,LC,

在新修改的uart2.c文件的uart2\u init函数(uint16\u t baudr,uint8\u t dlf\u value,uint8\u t mode)中,第二个参数dlf\u value的设置是什么?在我的uart2.c文件中不需要此参数。

Shouldn't you then have to also send me the uart2.h file too?
谢谢,
--Khai

LC\U对话框
Offline
Last seen:2 weeks 2 days ago
Staff
加入:2016-09-19 23:20
你好,凯,

你好,凯,

请在这里使用附加的头文件。最新版本的uart驱动程序中几乎没有更新。

Best,
LC

Attachment: