Announcements

Ever wondered how you could shape the future in collaboration with others? Join us at OktoberTech Asia Pacific and get inspired. Click here to sign up FREE of charge.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

zhji_4006061
Level 3
First solution authored 10 questions asked 25 sign-ins
Level 3

Hi  all :

  我想通过DMA读取ADC采样数据(不通过dma是可以读到采样数据的),dma组件通过tr_in连接adc的 eos,配置如下图:

adcdma.jpg

DMA组件的配置如下图:

dmaconfig.jpg

我初始化了一个500个成员的数组,期望将ADC的数据放到数组中保存。

dma初始化代码如下:

uint16_t  usData[500] = {0};

DMA_US_Start((uint32*) SAR->CHAN_RESULT[0], (void *)&usData[0]);

目前的情况是 usData中的数据一直为0,无法获取ADC采样数据,请问是DMA配置有问题吗?还是ADC的eos没触发?谢谢!

 

0 Likes
1 Solution
YuZh
Moderator
Moderator 10 likes received 50 sign-ins 50 replies posted
Moderator

Hi:

看来是MA_US_Start((uint32*) SAR->CHAN_RESULT[0], (void *)&usData[0]);函数的问题,不能大包大揽,还是要一步步调用,我那会也在想,从你的图形界面来看,没啥配置问题,看来还是接口调用初始化DMA的问题。

View solution in original post

0 Likes
4 Replies
YuZh
Moderator
Moderator 10 likes received 50 sign-ins 50 replies posted
Moderator

Hi:

不好意思,PSOC6 Creator我用的也不多,你稍等下,我先试一下,然后我再告诉您怎么正确使用。

0 Likes
YuZh
Moderator
Moderator 10 likes received 50 sign-ins 50 replies posted
Moderator

Hi:

能把完整的代码发一下吗。

谢谢

0 Likes
zhji_4006061
Level 3
First solution authored 10 questions asked 25 sign-ins
Level 3

我今天在调试中解决了该问题,主要是修改了DMA初始化代码,如下

DMA_US_SetDescriptorType(&DMA_US_Descriptor_1, CY_DMA_2D_TRANSFER);

DMA_US_Init();

DMA_US_SetSrcAddress(&DMA_US_Descriptor_1, (uint32*) &ADC_US_SAR__HW->CHAN_RESULT[0UL]);
DMA_US_SetDstAddress(&DMA_US_Descriptor_1, (uint32*) usData);

DMA_US_ChannelEnable();
Cy_DMA_Enable(DMA_US_HW);

取代了之前的:

DMA_US_Start((uint32*) SAR->CHAN_RESULT[0], (void *)&usData[0]);

0 Likes
YuZh
Moderator
Moderator 10 likes received 50 sign-ins 50 replies posted
Moderator

Hi:

看来是MA_US_Start((uint32*) SAR->CHAN_RESULT[0], (void *)&usData[0]);函数的问题,不能大包大揽,还是要一步步调用,我那会也在想,从你的图形界面来看,没啥配置问题,看来还是接口调用初始化DMA的问题。

0 Likes