2015-09-28 07:08 AM
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
2015-09-28 09:39 AM
You want it to restart immediately, or some time in the future.
The former, use circular DMA, the latter you're going to have reconfigure the DMA and ADC. You'll want to separate the NVIC/Clock stuff, so you can minimize the work required in subsequent restarts. You'll likely have to reset the ADC to get things back in sync.2015-09-29 01:16 AM
to be honest a restart once i have read the values will suffice, so i need to set them up again, without the NVIC stuff
2015-09-29 01:17 AM
Just noticed I do have the DMA as circular but I only get 1 interrupt
joolz