Question
STM32l152c Discovery board, DMA Stops after reading correct number of ADC values, would like to start again
Posted on September 28, 2015 at 16:08
Change my code now to use multiple channels and added in DMA.
If I ask the DMA to give me 4 sample from 3 channels, I get the 12 samples, whats the correct way to get the DMA to start againvoid DMA1_Channel1_IRQHandler(void)
{
if( DMA_GetITStatus(DMA1_IT_TC1)) {
DMA_ClearITPendingBit(DMA1_IT_GL1);
}
}
Dma setup
/* Configuration ------------------------------------------------------*/
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);
//reset DMA1 channe1 to default values;
DMA_DeInit(WHICH_DMA_CHANNEL);
//channel will be used for memory to memory transfer
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
//setting normal mode (non circular)
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
//medium priority
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
//source and destination data size word=32bit
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
//automatic memory destination increment enable.
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
//source address increment disable
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
//Location assigned to peripheral register will be source
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
//chunk of data to be transfered
DMA_InitStructure.DMA_BufferSize = setup->adc_setups * 8;
//source and destination start addresses
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(ADC1->DR);
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)adc1_read_value;
//send values to DMA registers
DMA_Init(WHICH_DMA_CHANNEL, &DMA_InitStructure);
// Enable DMA1 Channel Transfer Complete interrupt
DMA_ITConfig(WHICH_DMA_CHANNEL, DMA_IT_TC, ENABLE);
//Enable the WHICH_DMA
DMA_Cmd(WHICH_DMA_CHANNEL, ENABLE);
//Enable channel IRQ Channel */
NVIC_InitStructure.NVIC_IRQChannel = WHICH_DMA_CHANNEL_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
WHICH_DMA is DMA1
WHICH_DMA_CHANNEL is DMA1_Channel1
WHICH_DMA_CHANNEL_IRQn is DMA1_Channel1_IRQn
Now I get the IRQ once and would like to start it again.
ADC has the following
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
joolz