串口高频接收数据

tommy.guo
Posts: 24
Joined: Mon Feb 14, 2022 8:09 am

串口高频接收数据

Postby tommy.guo » Mon Jun 27, 2022 5:21 pm

请教各位一个问题
串口1波特率为921600,以10hz的频率接收数据,每次接受的数据有两条,第一条数据是147字节,以\n结尾,第二条是205字节,以\n结尾,这两条是连续的,
检测设置如下
uart_enable_pattern_det_baud_intr(uart_port, '\n', 1, 9, 0, 0);
代码中Pattern Queue Size是20,
RING_BUFFER_SIZE是2048,
但是一直显示以下warning,会丢失数据

Code: Select all

W (8464) uart1: Ring Buffer Full
W (8514) uart1: Pattern Queue Size too small
W (8614) uart1: pos:83
W (8714) uart1: pos:147
W (8814) uart1: pos:205
W (8914) uart1: pos:147
W (9014) uart1: pos:205
W (9114) uart1: pos:147
W (9214) uart1: pos:205
W (9314) uart1: pos:147
W (9414) uart1: pos:205
W (9514) uart1: pos:147
W (9614) uart1: pos:205
W (9714) uart1: pos:147
W (9814) uart1: pos:205
W (9914) uart1: pos:147
W (10014) uart1: pos:205
W (10114) uart1: pos:147
W (10214) uart1: pos:205
W (10264) uart1: Ring Buffer Full
W (10314) uart1: Pattern Queue Size too small

tommy.guo
Posts: 24
Joined: Mon Feb 14, 2022 8:09 am

Re: 串口高频接收数据

Postby tommy.guo » Tue Jun 28, 2022 3:12 pm

接收函数中,只是将数据uart_pattern_pop_pos之后uart_read_bytes读出来,并没有做其他操作,这样还是处理不及时?

Lifeihai
Posts: 9
Joined: Sat Dec 18, 2021 6:49 am

Re: 串口高频接收数据

Postby Lifeihai » Tue May 09, 2023 2:52 am

官方的串口例程并不好用,用的是队列在空闲的时候接收,即使不运行其他历程只接收在队列满了后释放队列过程中有数据来了就会丢了。有两种方法,1.每次传少于队列长度的数据,然后发送端等待一会再继续发。2.不要使用队列方式,也就是不要用uart_driver_install,然后和你写单片机驱动一样去写串口驱动。串口有缓冲区,最大可以设置1024字节,多快都不会丢数据。所有芯片官方例程只是参考,只会套例程不会写出高效率程序~

Who is online

Users browsing this forum: No registered users and 40 guests