2022-12-12 05:41 AM
I have Nucleo U575ZI-Q board and I am trying to unable ADC with DMA and Interrupt but not able to get any reading.
I am trying to see the adcBuf value in live expression but it is not working.
/* USER CODE BEGIN Includes */
#define max_channel 2
uint32_t adcBuf[max_channel];
uint32_t test=0;
/* USER CODE END Includes */
ADC_HandleTypeDef hadc1;
DMA_NodeTypeDef Node_GPDMA1_Channel0;
DMA_QListTypeDef List_GPDMA1_Channel0;
DMA_HandleTypeDef handle_GPDMA1_Channel0;
UART_HandleTypeDef huart1;
PCD_HandleTypeDef hpcd_USB_OTG_FS;
void SystemClock_Config(void);
static void SystemPower_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
static void MX_UCPD1_Init(void);
static void MX_GPDMA1_Init(void);
static void MX_USB_OTG_FS_PCD_Init(void);
static void MX_USART1_UART_Init(void);
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the System Power */
SystemPower_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_UCPD1_Init();
MX_GPDMA1_Init();
MX_USB_OTG_FS_PCD_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuf, max_channel);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/* USER CODE BEGIN 4 */
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
test++;
}
/* USER CODE END 4 */
2022-12-12 07:41 AM
Hello @Bhavik,
Which STM32CubeMX version are you using?
Try to move the MX_GPDMA1_Init(); line code before MX_ADC1_Init(); in your main.c.
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-12 08:06 AM
Hi @Bhavik ,
If you use the STM32CubeMX 6.7.0 version could you please share the .ioc file?
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-12 09:16 PM
@KDJEM.1 I tried in two different version of the STM32CubeIDE which are 1.10.1 and 1.9.0
2022-12-12 09:36 PM
@KDJEM.1 No I am not using the CubeMX
2022-12-13 01:01 AM
Hello @Bhavik,
Try to use the last version for STM32CubeIDE1.11.0.
You can download the latest version from this link.
Please let me know if the problem is solved.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-13 04:26 AM
@KDJEM.1 No update issue remains same. I am trying to debug and can not see any change in the variable test as well as adcBuf.
2022-12-13 04:55 AM
@KDJEM.1 Even I tried to close the DMA and just make it work on simple interrupt base but no success. It is returning the error on first time and busy on second time call for HAL_ADC_Start_IT(&hadc1)