2018-01-15 05:27 AM
I use STM32F767 series MCU,when i configure the single ADC DMA with external 200kHz trigger; The data size is right ,but data value Error,Is my use legal?
RHEOSTAT_ADC_DMA_CLK_ENABLE();
DMA_Init_HandleMain.Instance = RHEOSTAT_ADC_DMA2_STREAM_Main;
DMA_Init_HandleMain.Init.Direction = DMA_PERIPH_TO_MEMORY;
DMA_Init_HandleMain.Init.PeriphInc = DMA_PINC_DISABLE;
DMA_Init_HandleMain.Init.MemInc = DMA_MINC_ENABLE;
DMA_Init_HandleMain.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
DMA_Init_HandleMain.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
DMA_Init_HandleMain.Init.Mode = DMA_NORMAL;
DMA_Init_HandleMain.Init.Priority = DMA_PRIORITY_HIGH;
DMA_Init_HandleMain.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
DMA_Init_HandleMain.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
DMA_Init_HandleMain.Init.MemBurst = DMA_MBURST_SINGLE; DMA_Init_HandleMain.Init.PeriphBurst = DMA_PBURST_SINGLE;DMA_Init_HandleMain.Init.Channel = RHEOSTAT_ADC_DMA2_CHANNEL_MAIN;
DMA_Init_HandleMain.Parent = (void *)&ADC_HandleMain; ADC_HandleMain.DMA_Handle = &DMA_Init_HandleMain; d_ADC_DMAInitStat = HAL_DMA_Init(ADC_HandleMain.DMA_Handle); HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 1, 0); HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); RHEOSTAT_ADC_MAIN_CLK_ENABLE();// ADC1
ADC_HandleMain.Instance = RHEOSTAT_ADC1; // 时钟为fpclk 4分频 ADC_HandleMain.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;ADC_HandleMain.Init.Resolution = ADC_RESOLUTION_12B;
ADC_HandleMain.Init.ScanConvMode = DISABLE;
ADC_HandleMain.Init.ContinuousConvMode = DISABLE;
ADC_HandleMain.Init.DiscontinuousConvMode = DISABLE; ADC_HandleMain.Init.NbrOfDiscConversion = 0; ADC_HandleMain.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING; ADC_HandleMain.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_EXT_IT11; ADC_HandleMain.Init.DataAlign = ADC_DATAALIGN_RIGHT; ADC_HandleMain.Init.NbrOfConversion = 1; ADC_HandleMain.Init.DMAContinuousRequests = ENABLE; ADC_HandleMain.Init.EOCSelection = 1; HAL_ADC_Init(&ADC_HandleMain); ADC_Config.Channel = RHEOSTAT_ADC_CHANNEL_Main; ADC_Config.Rank = ADC_REGULAR_RANK_1; ADC_Config.SamplingTime = ADC_SAMPLETIME_3CYCLES;// é‡‡æ ·æ—¶é—´é—´éš�? ADC_Config.Offset = 0; d_ADC_DMAInitStat |= HAL_ADC_ConfigChannel(&ADC_HandleMain, &ADC_Config);