cancel
Showing results for 
Search instead for 
Did you mean: 

How to add an ADC multichannel conversion in stm32wb p2p server?

MGost.1
Associate

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:

0693W00000GWUCZQA5.png0693W00000GWUCKQA5.png 

// 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

0693W00000GWUA9QAP.png0693W00000GWU9kQAH.png

0 REPLIES 0