How does S32K312 UART receive variable length data using FIFO and DMA.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How does S32K312 UART receive variable length data using FIFO and DMA.

5,194 Views
li3
Contributor II

你好

请问S32K312 UART如何使用FIFO和DMA来接收可变长度数据?请在代码中给出示例和注释。

谢谢。

0 Kudos
Reply
13 Replies

3,053 Views
dujunqiu
Contributor I

我目前使用  Lpuart_Uart_Ip_GetReceiveStatus() 阻塞判断;

或者  Lpuart_Uart_Ip_SyncReceive() 手动计算从末尾起,第一个不等于 0x00的数据;

感觉两个方法都不是很靠谱

0 Kudos
Reply

1,199 Views
LZY
Contributor II
nxp 有类似串口总线空闲中断这种东西吗
串口空闲中断后触发dma搬运
刚接触nxp,有点懵
这个不定长串口数据接收真的很实用
0 Kudos
Reply

5,167 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@li3

没有完全符合你需求的demo供你参考,这里是一些实现UART+DMA的讨论和例程。

https://community.nxp.com/t5/S32K/S32K3-LPUART-using-DMA-in-RTD-3-0-0/td-p/1737356

 

0 Kudos
Reply

5,164 Views
li3
Contributor II

Hello, Senlent.

May I ask how the S32K312 UART only uses FIFO to receive data of indefinite length? Can you give an example?

thank you.

0 Kudos
Reply

5,152 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@li3

你能和我解释下什么叫接收不固定长度的数据?或者你的意图是什么?

你在使用Lpuart_Uart_Ip_AsyncReceive的时候,size不是可以自己定吗?

0 Kudos
Reply

3,050 Views
dujunqiu
Contributor I
就是使用串口API读取数据的时候,没办法判断已经读取数据的个数;
比如size定义128,实际只读取了16byte, 但是没办法判断读取了16byte
0 Kudos
Reply

5,146 Views
li3
Contributor II

你好 Senlent,

例如:Lpuart_Uart_Ip_AsyncReceive函数大小等于5,可以收到5个数据。如果需要接收3个、4个、6个或者更多数据怎么办。
0 Kudos
Reply

5,142 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@li3

那不是可以直接改Lpuart_Uart_Ip_AsyncReceive的接收size吗?

0 Kudos
Reply

5,125 Views
li3
Contributor II

你好 Senlent,

如果size等于5,那么收到6个数据就会丢失一个。
如果每次改size需要改代码烧录,不定长接收是为了可以接收到所有长度数据。
我想分别测试用FIFO和DMA方式接收不定长数据。
0 Kudos
Reply

5,119 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@li3

"如果size等于5,那么收到6个数据就会丢失一个"

为什么会得出这样的结论?

 

0 Kudos
Reply

5,116 Views
li3
Contributor II

你好 Senlent,

采用中断接收size等于5,我使用串口工具发送6个数据,用Debug方式查看接收buffer,只能看到5个数据。
另外我是想问分别使用FIFO和DMA怎么接收不定长的数据,不使用size定长。
0 Kudos
Reply

4,441 Views
haha_123456
Contributor I
Hi li3, 你的问题得到解决了吗?
0 Kudos
Reply

4,432 Views
li3
Contributor II
没有呢,我正想了个方案,可以交流一下嘿嘿。
微信:Ncommonness
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1841781%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3EHow%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1841781%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EHow%20are%20you%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EHow%20can%20S32K312%20UART%20use%20FIFO%20and%20DMA%20to%20receive%20variable%20length%20data%3F%20Please%20give%20example%20and%20comments%20in%20the%20code.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EThank%20you.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2316432%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2316432%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Enxp%20%E6%9C%89%E7%B1%BB%E4%BC%BC%E4%B8%B2%E5%8F%A3%E6%80%BB%E7%BA%BF%E7%A9%BA%E9%97%B2%E4%B8%AD%E6%96%AD%E8%BF%99%E7%A7%8D%E4%B8%9C%E8%A5%BF%E5%90%97%3CBR%20%2F%3E%E4%B8%B2%E5%8F%A3%E7%A9%BA%E9%97%B2%E4%B8%AD%E6%96%AD%E5%90%8E%E8%A7%A6%E5%8F%91dma%E6%90%AC%E8%BF%90%3CBR%20%2F%3E%E5%88%9A%E6%8E%A5%E8%A7%A6nxp%EF%BC%8C%E6%9C%89%E7%82%B9%E6%87%B5%3CBR%20%2F%3E%E8%BF%99%E4%B8%AA%E4%B8%8D%E5%AE%9A%E9%95%BF%E4%B8%B2%E5%8F%A3%E6%95%B0%E6%8D%AE%E6%8E%A5%E6%94%B6%E7%9C%9F%E7%9A%84%E5%BE%88%E5%AE%9E%E7%94%A8%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2106047%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2106047%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3EThat%20is%2C%20when%20using%20the%20serial%20port%20API%20to%20read%20data%2C%20there%20is%20no%20way%20to%20determine%20the%20number%20of%20data%20that%20has%20been%20read%3B%20%3CBR%20%2F%3EFor%20example%2C%20if%20size%20is%20defined%20as%20128%2C%20only%2016%20bytes%20are%20actually%20read%2C%20but%20there%20is%20no%20way%20to%20determine%20the%20number%20of%2016%20bytes%20read.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2106042%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2106042%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20currently%20use%20%3CSPAN%3ELpuart_Uart_Ip_GetReceiveStatus()%20to%20block%20the%20judgment%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eor%20%20%3C%2FSPAN%3E%3CSPAN%3E%20Lpuart_Uart_Ip_SyncReceive()%20manually%20calculates%20the%20first%20data%20from%20the%20end%20that%20is%20not%20equal%20to%200x00%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ENeither%20method%20feels%20very%20reliable%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1937234%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1937234%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3ENo%20it%20doesn't%2C%20I'm%20thinking%20of%20a%20program%20to%20exchange%20hehehe.%20%3CBR%20%2F%3EWeChat%3A%20Ncommonness%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1937214%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1937214%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3EHi%20li3%2C%20did%20you%20get%20your%20problem%20solved%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1842165%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1842165%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHello%20Senlent.%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3EUsing%20interrupt%20receive%20size%20equal%20to%205%2C%20I%20send%206%20data%20using%20the%20serial%20tool%2C%20and%20when%20I%20look%20at%20the%20receive%20buffer%20using%20Debug%2C%20I%20can%20only%20see%205%20data.%3C%2FDIV%3E%3CDIV%3EAlso%20I%20was%20asking%20how%20to%20receive%20data%20of%20indefinite%20length%20without%20using%20size%20fixed%20length%20using%20FIFO%20and%20DMA%20respectively.%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1842143%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1842143%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%40%3CA%20id%3D%22link_6%22%20class%3D%22lia-link-navigation%20lia-page-link%20lia-user-name-link%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F231581%22%20target%3D%22_self%22%20aria-label%3D%22View%20Profile%20of%20li3%22%3E%3CSPAN%20class%3D%22%22%3E%20li3%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22%22%3E%22%3CSPAN%3EIf%20size%20is%20equal%20to%205%2C%20then%20if%206%20data%20are%20received%2C%20one%20will%20be%20lost%3C%2FSPAN%3E%22%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22%22%3EWhy%20did%20you%20come%20to%20this%20conclusion%3F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1842132%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1842132%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHello%20Senlent.%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E%3CFONT%3EIf%20size%20is%20equal%20to%205%2C%20then%20one%20of%20the%20six%20data%20received%20will%20be%20lost.%3C%2FFONT%3E%3C%2FDIV%3E%3CDIV%3E%3CFONT%3EIf%20you%20need%20to%20change%20the%20code%20burning%20every%20time%20you%20change%20the%20size%2C%20the%20indefinite%20length%20reception%20is%20so%20that%20you%20can%20receive%20all%20the%20length%20data.%3C%2FFONT%3E%3C%2FDIV%3E%3CDIV%3E%3CFONT%3EI%20want%20to%20test%20receiving%20indeterminate%20length%20data%20using%20FIFO%20and%20DMA%20respectively.%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1842100%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1842100%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40LI3%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40li3%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EWouldn't%20that%20just%20change%20the%20receive%20size%20of%20Lpuart_Uart_Ip_AsyncReceive%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1842097%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1842097%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHello%20Senlent.%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E%3CFONT%3EFor%20example%2C%20the%20Lpuart_Uart_Ip_AsyncReceive%20function%20size%20is%20equal%20to%205%20and%20can%20receive%205%20data.%20What%20if%20you%20need%20to%20receive%203%2C%204%2C%206%20or%20more%20data.%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1842086%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1842086%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3E%3CA%20href%3D%22mailto%3AHi%40li3%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40li3%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ECan%20you%20explain%20to%20me%20what%20you%20mean%20by%20receiving%20data%20of%20variable%20length%3F%20Or%20what%20is%20your%20intention%3F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIsn't%20the%20size%20something%20you%20can%20set%20yourself%20when%20you%20use%20Lpuart_Uart_Ip_AsyncReceive%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1841915%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1841915%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EHello%2C%20Senlent.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EMay%20I%20ask%20how%20the%20S32K312%20UART%20only%20uses%20FIFO%20to%20receive%20data%20of%20indefinite%20length%3F%20Can%20you%20give%20an%20example%3F%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3Ethank%20you.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1841896%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20does%20S32K312%20UART%20receive%20variable%20length%20data%20using%20FIFO%20and%20DMA.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1841896%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40li3%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EHi%40li3%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EThere%20is%20no%20demo%20that%20fully%20meets%20your%20needs%20for%20your%20reference%2C%20here%20are%20some%20discussions%20and%20routines%20that%20implement%20UART%2BDMA.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K3-LPUART-using-DMA-in-RTD-3-0-0%2Ftd-p%2F1737356%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K3-LPUART-using-DMA-in-RTD-3-0-0%2Ftd-p%2F1737356%3C%2FA%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E