Receive sai multichannel data into multiple buffs using sdma

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Receive sai multichannel data into multiple buffs using sdma

跳至解决方案
343 次查看
tongt
Contributor I

使用sdma接收sai多通道数据到多个buff中

Receive sai multichannel data into multiple buffs using sdma

在使用sai及sdma接收数据的时候,如果使用multififo等机制,接收到的数据会在一个buff中,能不能使用sdma的多通道功能,使接收到的数据按照通道分散到各执的buff中?

When using sai and sdma to receive data, if you use such as multififo, the received data will be in a buff, can you use the multi-channel function of sdma so that the received data is dispersed according to the channel in the buff of each execution?

_1-1715928528878.png

以上图为例子,第一组4字节为第一个通道,连续的第二组4字节为第二个通道,总共4个通道,实际使用的时候需要对某一个通道的数据进行拷贝,拷贝出一个完整通道的数据
The above figure as an example, the first group of 4 bytes for the first channel, the second consecutive group of 4 bytes for the second channel, a total of 4 channels, the actual use of the time you need to copy the data of a channel, copy out a complete channel data

我尝试使用如下代码,但是回调函数总是不能被调用

I tried to use the following code, but the callback function always fails to be called

_0-1715927543295.png

这种方案有没有问题,能不能实现,如果要实现需要关注哪些呢?

Are there any problems with this option, can it be achieved, and what needs to be focused on if it is to be achieved?

0 项奖励
1 解答
168 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

在未对SDK大幅改动的情况下,不行,而且目前的sdma脚本只支持交错存储,不支持自定义的多个buffer地址。

在原帖中查看解决方案

0 项奖励
7 回复数
252 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @tongt 

你的这个想法已经在SDK里集成了,但是用法不对。smda script里有针对SAI multi-fifo的脚本,详细参数请看手册的 A.3.2.8 mcu_2_sai 

Zhiming_Liu_0-1716268355591.png

Zhiming_Liu_1-1716268459452.png

SDK里的SAI_TransferSendSDMA  API也支持script里的这个功能,如果配置的通道数大于1,SAI_TransferSendSDMA 里会使用milti-fifo这个功能读取数据,然后返回第一个buffer,对于其余的buffer,是在这个buffer基础上+offset(默认是4U)。callback应该是一个就行,然后指定通道的时候用或逻辑试试。然后设置saiConfig里的channelNums和channelMask

Zhiming_Liu_2-1716269676812.png

Zhiming_Liu_3-1716270334737.png

 

0 项奖励
176 次查看
tongt
Contributor I

@Zhiming_Liu 下午好

目前接收是使用了multi fifo的。offset的类型为uint8_t,也就是最大为255,如果需要buff的偏移更大,有没有办法呢(目前每次接收64K数据,包含4个通道,每4个字节交错),如果不使用offset,如之前说的,4个通道能不能对应到sdma的4个通道上,这4个sdma的通道对应4个不同的buff地址,能不能实现呢

0 项奖励
169 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

在未对SDK大幅改动的情况下,不行,而且目前的sdma脚本只支持交错存储,不支持自定义的多个buffer地址。

0 项奖励
165 次查看
tongt
Contributor I
谢谢
0 项奖励
278 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @tongt 

你用的是哪颗芯片?

0 项奖励
264 次查看
tongt
Contributor I
imx8mp
0 项奖励
260 次查看
tongt
Contributor I

另外我还修改了 SAI_TransferRxCreateHandleSDMA以及

/*<! Private handle only used for internally. */
static sai_sdma_private_handle_t s_sdmaPrivateHandle[ARRAY_SIZE(s_saiBases)][16];

tongt_0-1716261721673.png

@Zhiming_Liu 感谢回复

0 项奖励