cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ADC channel 10~16 in the Nucleo-WB55 board? The 1-9 is successfully working but the ADC is not working from 10.

KKIM.6
Senior

I'm designing multichannel ADC using scan conversion mode.

Using HAL_ADC_Start_DMA code, the 1~9 ADC is easily saved in the DMA but. from 10, the ADC is not working and I cannot see any UART communication data.

​​

How to use ADC channel 10~16 in the Nucleo-WB55 board or is there anything I missed? 

In addition, is there any exam sending the row data from the WB55 board to the PC through Bluetooth?

here is the code.

#include "main.h"

#include "stm32_seq.h"

#include "string.h"

#include "stdio.h"

ADC_HandleTypeDef hadc1;

DMA_HandleTypeDef hdma_adc1;

HAL_StatusTypeDef ret;

UART_HandleTypeDef huart1;

ADC_ChannelConfTypeDef sConfig;

float value[16];

uint16_t DMA_value[16];

int main(void)

{

 HAL_Init();

 MX_APPE_Config();

 SystemClock_Config();

 PeriphCommonClock_Config();

 MX_IPCC_Init();

 MX_GPIO_Init();

 MX_DMA_Init();

 MX_RF_Init();

 MX_RTC_Init();

 MX_USB_PCD_Init();

 MX_ADC1_Init();

 MX_APPE_Init();

 MX_APPE_Process();

 HAL_ADC_Start_DMA(&hadc1,(uint32_t*)DMA_value, 16);

 while (1)

 {

 HAL_ADC_Start(&hadc1);

 HAL_Delay(100);

   printf("%.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t %.d\t \r\n", DMA_value[0],DMA_value[1],DMA_value[2],DMA_value[3],DMA_value[4],DMA_value[5],DMA_value[6],DMA_value[7],DMA_value[8],DMA_value[9],DMA_value[10],DMA_value[11],DMA_value[12],DMA_value[13],DMA_value[14],DMA_value[15]);

   fflush(stdout);

 }

}

static void MX_ADC1_Init(void)

{

 hadc1.Instance = ADC1;

 hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;

 hadc1.Init.Resolution = ADC_RESOLUTION_12B;

 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;

 hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;

 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

 hadc1.Init.LowPowerAutoWait = DISABLE;

 hadc1.Init.ContinuousConvMode = DISABLE;

 hadc1.Init.NbrOfConversion = 15;

 hadc1.Init.DiscontinuousConvMode = DISABLE;

 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;

 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

 hadc1.Init.DMAContinuousRequests = ENABLE;

 hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;

 hadc1.Init.OversamplingMode = ENABLE;

 hadc1.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_256;

 hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4;

 hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;

 hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;

 if (HAL_ADC_Init(&hadc1) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_1;

 sConfig.Rank = ADC_REGULAR_RANK_1;

 sConfig.SamplingTime = ADC_SAMPLETIME_47CYCLES_5;

 sConfig.SingleDiff = ADC_SINGLE_ENDED;

 sConfig.OffsetNumber = ADC_OFFSET_NONE;

 sConfig.Offset = 0;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_2;

 sConfig.Rank = ADC_REGULAR_RANK_2;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_3;

 sConfig.Rank = ADC_REGULAR_RANK_3;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_4;

 sConfig.Rank = ADC_REGULAR_RANK_4;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_5;

 sConfig.Rank = ADC_REGULAR_RANK_5;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_6;

 sConfig.Rank = ADC_REGULAR_RANK_6;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_7;

 sConfig.Rank = ADC_REGULAR_RANK_7;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_8;

 sConfig.Rank = ADC_REGULAR_RANK_8;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_9;

 sConfig.Rank = ADC_REGULAR_RANK_9;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 sConfig.Channel = ADC_CHANNEL_10;

 sConfig.Rank = ADC_REGULAR_RANK_10;

 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

}

2 REPLIES 2
TDK
Guru

> sConfig.Channel = ADC_CHANNEL_10;

> sConfig.Rank = ADC_REGULAR_RANK_10;

Looks like your code is only initializing 10 channels. To use more than 10 channels, you will need to initialize the other in a similar fashion to the first 10.

If you feel a post has answered your question, please click "Accept as Solution".
KKIM.6
Senior

this problem is solved by using STM32CubeMX. I think the previous setting has something wrong. Now all 16 channel works successfully and I can save them into the DMA.