Me gustaría saber cuántas muestras tengo por segundo para el ADC y cuál es su máximo de muestras por segundo y ¿puedo obtener una muestra por 1 µs?
Reloj: 84 Mhz
El tablero es Nucleo F401RE
Aquí está la configuración de ADC con DMA:
void ConfigureDMA_ADC() {
__DMA2_CLK_ENABLE()
;
g_DmaHandle.Instance = DMA2_Stream4;
g_DmaHandle.Init.Channel = DMA_CHANNEL_0;
g_DmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
g_DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
g_DmaHandle.Init.MemInc = DMA_MINC_ENABLE;
g_DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
g_DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
g_DmaHandle.Init.Mode = DMA_CIRCULAR;
g_DmaHandle.Init.Priority = DMA_PRIORITY_HIGH;
g_DmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
g_DmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL;
g_DmaHandle.Init.MemBurst = DMA_MBURST_SINGLE;
g_DmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE;
HAL_DMA_Init(&g_DmaHandle);
__HAL_LINKDMA(&g_AdcHandle, DMA_Handle, g_DmaHandle);
HAL_NVIC_SetPriority(DMA2_Stream4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn);
}
void ConfigureADC() {
GPIO_InitTypeDef gpioInit;
__GPIOA_CLK_ENABLE()
;
__ADC1_CLK_ENABLE()
;
gpioInit.Pin = GPIO_PIN_1;
gpioInit.Mode = GPIO_MODE_ANALOG;
gpioInit.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &gpioInit);
HAL_NVIC_SetPriority(ADC_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(ADC_IRQn);
ADC_ChannelConfTypeDef adcChannel;
g_AdcHandle.Instance = ADC1;
g_AdcHandle.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;
g_AdcHandle.Init.Resolution = ADC_RESOLUTION_12B;
g_AdcHandle.Init.ScanConvMode = DISABLE;
g_AdcHandle.Init.ContinuousConvMode = ENABLE;
g_AdcHandle.Init.DiscontinuousConvMode = DISABLE;
g_AdcHandle.Init.NbrOfDiscConversion = 0;
g_AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
g_AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1;
g_AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;
g_AdcHandle.Init.NbrOfConversion = 1;
g_AdcHandle.Init.DMAContinuousRequests = ENABLE;
g_AdcHandle.Init.EOCSelection = DISABLE;
HAL_ADC_Init(&g_AdcHandle);
adcChannel.Channel = ADC_CHANNEL_1;
adcChannel.Rank = 1;
adcChannel.SamplingTime = ADC_SAMPLETIME_144CYCLES;
adcChannel.Offset = 0;
if (HAL_ADC_ConfigChannel(&g_AdcHandle, &adcChannel) != HAL_OK) {
asm("bkpt 255");
}
}