2009-05-30 02:38 PM
Is it possible to use external SRAM as DMA memory for ADC?
2011-05-17 04:13 AM
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!2011-05-17 04:13 AM
For the USART I also tried to use the DMA in conjunction with the external SRAM. But it also did not work. So, maybe there is a special setup that the DMA can also write to the external memory.
But probably it is simply impossible to do this!!! If so, it would be nice, if STM could confirm this! Regards, Michael2011-05-17 04:13 AM
I'm using DMA to transfer data from SPI to external memory and I have no problem using it.
[ This message was edited by: slawcus on 29-05-2009 10:19 ]2011-05-17 04:13 AM
Is there anyone who has the similar experience? Is it because the speed of accessing external SRAM is slower than internal SRAM. But the ADC has already worked at the slowest speed.