LPADC module multiple channels readings using with DMA

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

LPADC module multiple channels readings using with DMA

69 Views
burhanhagi
Contributor III
  • I am measuring nearly 17 Analog Inputs on my custom board with IMXRT1170 ADC.
  • I am using both LPADC1 and LPADC2 for that.
  • I can successfully read either analog inputs on LPADC1 or LPADC2 with eDMA with correct order to SRAM. However I can not read both LPADC1 and LPADC2 at the same time. I tried the same code in IMXRT1166-EVK in my hand. 
  • I created my code from "evkmimxrt1160_lpadc_high_sample_rate_sample_signal_cm7" in SDK v.2.14.
  • Here is my code snippet regarding eDMA INIT function;

static void DEMO_EDMAInit(void){

edma_config_t userConfig;

DMAMUX_Init(DEMO_DMAMUX_BASE);

 

DMAMUX_SetSource(DEMO_DMAMUX_BASE, DEMO_DMA_CHANNEL, DEMO_DMA_SOURCE);

DMAMUX_EnableChannel(DEMO_DMAMUX_BASE, DEMO_DMA_CHANNEL);

 

 

DMAMUX_SetSource(DEMO_DMAMUX_BASE, DEMO_DMA_CHANNEL_for_ADC2, DEMO_DMA_SOURCE_for_ADC2);

DMAMUX_EnableChannel(DEMO_DMAMUX_BASE, DEMO_DMA_CHANNEL_for_ADC2);

 

EDMA_GetDefaultConfig(&userConfig);

userConfig.enableContinuousLinkMode = true;

userConfig.enableDebugMode = true;

 

EDMA_Init(DEMO_DMA_BASE, &userConfig);

 

EDMA_CreateHandle(&g_EDMA_Handle, DEMO_DMA_BASE, DEMO_DMA_CHANNEL);

EDMA_CreateHandle(&g_EDMA_Handle_for_ADC2, DEMO_DMA_BASE, DEMO_DMA_CHANNEL_for_ADC2);

 

EDMA_PrepareTransfer(&g_transferConfig, (void *)&(DEMO_LPADC_BASE->RESFIFO), 2U, ANALOG_INPUT_STATUS, sizeof(ANALOG_INPUT_STATUS[0]),

2U * 1U, (BUFF_LENGTH - 6U) * 2U, kEDMA_PeripheralToMemory);

 

EDMA_PrepareTransfer(&g_transferConfig_for_ADC2, (void *)&(LPADC2->RESFIFO), 2U, ANALOG_INPUT_STATUS1, sizeof(ANALOG_INPUT_STATUS1[0]),

(2U * 1U), (6U * 2U), kEDMA_PeripheralToMemory);

 

EDMA_TcdSetTransferConfig(&s_emdaTcd[0], &g_transferConfig, &s_emdaTcd[0]);

EDMA_TcdSetTransferConfig(&s_emdaTcd[1], &g_transferConfig_for_ADC2, &s_emdaTcd[1]);

 

EDMA_InstallTCD(DEMO_DMA_BASE, DEMO_DMA_CHANNEL, &s_emdaTcd[0]);

EDMA_InstallTCD(DEMO_DMA_BASE, DEMO_DMA_CHANNEL_for_ADC2, &s_emdaTcd[1]);

 

EDMA_StartTransfer(&g_EDMA_Handle);

EDMA_StartTransfer(&g_EDMA_Handle_for_ADC2);

}

 

  • How can I receive data from two LPADC modules and put those in SRAM with eDMA?

 

0 Kudos
Reply
1 Reply

19 Views
Habib_MS
NXP Employee
NXP Employee

Hello @burhanhagi,
Sorry for taking a while to get back to you. In order to support you better, can you provide me what happens when you cannot read (is the data received wrong, occurs a hard fault error, the DMA present an error)?

 

Also, the issue could be a channel priority error in the DMA, with the propose of try a pinpoint, can you change the priority of each DMA channel that you are currently using?

If you need more information about this error, you can consult the chapter 6.3.3 called "Fault reporting and handling" in the RM

BR
Habib.

0 Kudos
Reply