2021-11-04 07:51 AM
Hello everyone!
Could you, please, help me and explain how to use ADC in my p2p server application via DMA.
What have I done to get an ADC multichannel conversions in stm32wb app:
// in app_ble.c
/* USER CODE BEGIN HCI_EVT_LE_CONN_COMPLETE */
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_SET); // Program Start
if(start_counter != 0)
{
HAL_TIM_Base_Start_IT(&htim1);
HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &ADC_buffer, 2);
start_counter--;
}
so after connection device starts a TIM1 and ADC in DMA mode.
Then in app_entry.c I have defined two functions - ADC and TIM Callbacks. TIM1 callback works perfect and runs its task after each period overflow, but ADC Callback does not called.
/* USER CODE BEGIN FD_WRAP_FUNCTIONS */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim -> Instance == TIM1)
{
UTIL_SEQ_SetTask(1 << TIM1_ID, CFG_SCH_PRIO_0);
}
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
if(hadc -> Instance == ADC1)
{
UTIL_SEQ_SetTask(1 << ADC_ID, CFG_SCH_PRIO_0);
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_SET);
}
}
What should I do to Start ADC in DMA mode and Get a values from time to time ?
Thank you in advance