2022-09-21 05:50 AM
I have a STM32F103C8T6 bluepill board. I´m trying to use the Timer3 to TRIGGER the ADC1 conversion + DMA transfer.
The ideia is: when the timer 3 trigger the ADC1, a conversions starts and the dma transfer the result of conversion to a buffer, in circular mode.
I´m using the STMCubeIDE.
In the TIM3 Mode and Configurations, in the tab Parameters Setting, in the field Trigger Output (TRGO) Paramters, i´ve set Trigger Event Selection like Update Event. These settings are shown in the figure below.No modo e configuração ADC1 fiz a seguinte configuração.
The code:
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
TIM_HandleTypeDef htim3;
/* USER CODE BEGIN PV */
#define Buflen 10
uint16_t dmaBuffer[Buflen];
/* USER CODE END PV */
/* USER CODE BEGIN 2 */
HAL_ADCEx_Calibration_Start(&hadc1);
HAL_TIM_Base_Start(&htim3);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)dmaBuffer, Buflen);
/* USER CODE END 2 */
/* USER CODE BEGIN 4 */
void HAL_ADC_ConvCptCallBack(ADC_HandleTypeDef* hadc){
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_6);
}
/* USER CODE END 4 */
It's not working. I'm using an oscilloscope to analyse the GPIO PA6. Nothing happens there. The correct would i see a square wave at this port. i.e At each 10 conversions, the pin toggle the status.
What could be? Why it´s no working?
Solved! Go to Solution.
2022-09-22 07:03 PM
Thanks very much, but it wasn't necessary. I found the unblessed of the mistake.
The name of the function was written wrong. It was missing a letter.
The Correct: void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc1){
How i´ve written: void HAL_ADC_ConvCptCallback(ADC_HandleTypeDef* hadc1){
2022-09-21 06:13 AM
In debugger, read out and check/post TIM, ADC and DMA registers content.
JW
2022-09-22 07:03 PM
Thanks very much, but it wasn't necessary. I found the unblessed of the mistake.
The name of the function was written wrong. It was missing a letter.
The Correct: void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc1){
How i´ve written: void HAL_ADC_ConvCptCallback(ADC_HandleTypeDef* hadc1){