cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use external SRAM as DMA memory for ADC?

pipiluxixi1
Associate II
Posted on May 26, 2009 at 05:50

Is it possible to use external SRAM as DMA memory for ADC?

1 REPLY 1
pipiluxixi1
Associate II
Posted on May 17, 2011 at 13:13

I have a test project to use ADC1 with DMA.

ADC1: ScanConvMode = ENABLE;

ContinuousConvMode = ENABLE;

ADC_NbrOfChannel = 2;

DMA1_Channel1:

DMA_Mode = DMA_Mode_Circular;

DMA_M2M = DMA_M2M_Disable;

The Buffer Length equals 32. And I use DMA_ITConfig(DMA1_Channel1, DMA_IT_TC | DMA_IT_HT , ENABLE) to realize a double buffer. Some related code:

DMA_DeInit(DMA1_Channel1);

DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)ADC1_DR_Address;

DMA_InitStructure.DMA_MemoryBaseAddr = (u32)ADC_DualConvertedValueTab;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;

DMA_InitStructure.DMA_BufferSize = 32;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;

DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

DMA_InitStructure.DMA_Priority = DMA_Priority_High;

DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

DMA_Init(DMA1_Channel1, &DMA_InitStructure);

/* Enable DMA1 Channel1 Transfer Complete interrupt */

DMA_ITConfig(DMA1_Channel1, DMA_IT_TC | DMA_IT_HT , ENABLE);

/* Enable DMA1 Channel1 */

DMA_Cmd(DMA1_Channel1, ENABLE);

ADC_DualConvertedValueTab is an array defined elsewhere. The hardware is STM3210E-Eval board. When I use the internal RAM in STM32F103ZE, everything is OK, the DMA works continously as expected.

But when I try to use the external RAM(the configuration of the external RAM is OK and works correctly, ADC_DualConvertedValueTab is located in external RAM), the first DMA transfer is correct but the DMA can't work continously as expected.

I use J-link and MDK to debug the program and find that the TEIF1 is set(I can't grasp the definite DMA tansfer), which means some error occured during DMA transfer(according to the STM32 reference manual, the faulty channel is automatically disabled with through a hardware clear of its EN bit in the corresponding Channel Configuration Register (DMA_CCRx). The channel's transfer error interrupt flag (TEIF) in the DMA_IFR register is set and an interrupt is generated if the Transfer Error Interrupt Enable bit (TEIE) in the DMA_CCRx register is set).

Can anyone tell me why this error happened and is it impossible to use external RAM as the destination memory of DMA tranfser from peripheral?

Thank you very much!

[ This message was edited by: pipiluxixi1 on 26-05-2009 09:45 ]