A question about adc and dma for RT1052

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

A question about adc and dma for RT1052

3,147 Views
1668834026
Contributor I

hello,everyone.

   I have been making a example that ADC value transfers from DMA channel to memery. My idea is to trigger ADC sampling via software trigger, and then transmit the data via DMA to memery.But now,  the ADC can sample a value but Dma hasn't transfer the value, and I have searched for this reason two days. These pictures are code I wrote. Please help me see the problem ,  thanks.

Labels (1)
0 Kudos
3 Replies

3,006 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, 

Could you please provide more information about the behavior you are facing? For example, does your program crash at some point? Does the DMA request trigger correctly? Is your program getting stuck somewhere?

Regards,

Victor 

0 Kudos

3,006 Views
1668834026
Contributor I

Hello, Victor,

  

My program doesn't get stuck, and can read value of ADC1->R[0] register. However, it also doesn't trigger DMA transmission. So, I suspect that there is a set of DMA problem, but to find where the problem.  And I use ADC_SetChannelConfig() to trigger ADC sampling in main(). The DMA request is kDmaRequestMuxADC1.

Here is my configuration of DMA.

AT_NONCACHEABLE_SECTION_INIT(uint32_t destAddr[ECHO_BUFFER_LENGTH]) = {0x00, 0x00, 0x00, 0x00};//目的数据缓冲区

void ADC_DMA_Init(void)
{

edma_config_t userConfig;//定义eDMA初始化结构体
edma_handle_t g_ADCEdmaHandle;
edma_transfer_config_t transferConfig;//定义 edma 传输配置结构体

/*初始化DMAMUX */
DMAMUX_Init(DMAMUX);
/* 为DMA设置DMA传输通道*/
DMAMUX_SetSource(DMAMUX, 0U, kDmaRequestMuxADC1);
DMAMUX_EnableChannel(DMAMUX, 0U);



EDMA_GetDefaultConfig(&userConfig);
/*初始化eDAM*/
EDMA_Init(DMA0,&userConfig);

/*创建eDMA句柄*/
EDMA_CreateHandle(&g_ADCEdmaHandle, DMA0, 0U);
/*设置传输完成回调函数*/
EDMA_SetCallback(&g_ADCEdmaHandle, EDMA_Callback, NULL);

/*eDMA预传输,根据配置参数完成传输配置结构体的初始化*/
EDMA_PrepareTransfer(&transferConfig,\
(uint32_t *)ADC1->R[0],\
sizeof(uint32_t),\
destAddr,\
sizeof(destAddr[0]),\
sizeof(srcAddr[0]),\
sizeof(srcAddr),\
kEDMA_PeripheralToMemory);

/*提交eDAM传输请求*/
EDMA_SubmitTransfer(&g_ADCEdmaHandle, &transferConfig);
/*启动传输*/
EDMA_StartTransfer(&g_ADCEdmaHandle);

ADC_EnableDMA(ADC1, true);

}

0 Kudos

3,006 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, 

Thanks for providing more information about it. Please refer to the two application notes that my co-worker Jeremy mentioned in the following community post, ADC+DMA. These two application notes describe how to combine the ADC and DMA, even these documents are base on Kinetis MCU, you can use this for the RT since the RT and Kinetis share the ADC and DMA IPs.

Best Regards, 

Victor 

0 Kudos