AnsweredAssumed Answered

using ADC dual mode with DMA issue

Question asked by Timothy Smieja on Aug 2, 2017

I am working with the STM32F4 discovery board and trying to get the ADC1 and ADC2 working in simultaneous mode working with DMA. I am using the Keil uvision interface and compiler. I'm new to this processor and just getting familiar with the HAL interface. I have 4 pairs of channels that I want to sample in simultaneous mode and store each sample using DMA. I'm also not sure how to store the pairs separately in memory. But at this point it doesn't;t seem to store even one pair of measurement.

 

Currently I used the cube to configure the ADC and DMA, and have included a word document that contains the screen shots from cube of the ADC1 & 2 settings. I've tried using two different ADC start calls and see different results. I believe I need to use the Multi start call in order to use the dual mode, but it does not seem to be working. My guess is that I do not have something set correct, or am not doing something I need to do, or both. The listing of my code is below.

 

I have tried the following with the following results.

The results were the same whether I had global Interrupts unchecked or checked in Cube using the ADC multi DMA start.

HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADC1_Buffer, sizeof(ADC1_Buffer));

HAL_ADC_Start(&hadc2);

ADC1 has one value in the lower 16 bits of the DR, never changes after the first one.

No values in the memory buffer.

There are no values in the ADC2 DR.

There are no values in either of the C_ADC DR’s.

 

Same cube set up, but used the ADC start DMA HAL function.

HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADC1_Buffer, sizeof(ADC1_Buffer));

 HAL_ADC_Start(&hadc2);

ADC1 data register has the value stored in lower 16 bits.

Just zeros in the upper 16 bits of the ADC1 data reg.

ADC2 data register has 0’s

I get five values into the lower 16 bits in the memory buffer, and then five more values in the upper 16 bits. Looking at the values they all appear to be from the ADC1 input. They continue to constantly fill with new values.

 

Code

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_hal.h"

/* USER CODE BEGIN Includes */
/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
ADC_HandleTypeDef hadc2;
DMA_HandleTypeDef hdma_adc1;
DMA_HandleTypeDef hdma_adc2;

I2C_HandleTypeDef hi2c2;

SPI_HandleTypeDef hspi3;
SPI_HandleTypeDef hspi6;

UART_HandleTypeDef huart1;
UART_HandleTypeDef huart3;
DMA_HandleTypeDef hdma_usart1_rx;
DMA_HandleTypeDef hdma_usart1_tx;

/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_ADC1_Init(void);
static void MX_ADC2_Init(void);
static void MX_I2C2_Init(void);
static void MX_SPI3_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_SPI6_Init(void);
static void MX_USART1_UART_Init(void);

/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */

/* USER CODE BEGIN 0 */
/* USER CODE END 0 */

int main(void)
{

  /* USER CODE BEGIN 1 */
//uint16_t ADC1_Status;
//uint16_t buffer_Len;
//uint8_t i,j;
uint32_t ADC1_Buffer[5];
  /* 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();

  /* USER CODE BEGIN SysInit */
  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_ADC1_Init();
  MX_ADC2_Init();
  MX_I2C2_Init();
  MX_SPI3_Init();
  MX_USART3_UART_Init();
  MX_SPI6_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
// HAL_ADC_Start_DMA(&hadc1, ADC1_Buffer, sizeof(ADC1_Buffer));
 HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADC1_Buffer, sizeof(ADC1_Buffer));
// HAL_ADC_Start_DMA(&hadc2, (uint32_t*) ADC1_Buffer, buffer_Len);
// HAL_ADC_Start(&hadc1);
 HAL_ADC_Start(&hadc2);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {

/*blink the LEDs*/
   HAL_GPIO_WritePin(GPIOE, LED3_PE0_Pin, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, LED4_PE1_Pin, GPIO_PIN_RESET);
  HAL_Delay(50);
  HAL_GPIO_WritePin(GPIOE, LED3_PE0_Pin, GPIO_PIN_RESET);
  HAL_GPIO_WritePin(GPIOE, LED4_PE1_Pin, GPIO_PIN_SET);
  HAL_Delay(50);
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}

/** System Clock Configuration
*/
void SystemClock_Config(void)
{

  RCC_OscInitTypeDef RCC_OscInitStruct;
  RCC_ClkInitTypeDef RCC_ClkInitStruct;

    /**Configure the main internal regulator output voltage
    */
  __HAL_RCC_PWR_CLK_ENABLE();

  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);

    /**Initializes the CPU, AHB and APB busses clocks
    */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = 16;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Initializes the CPU, AHB and APB busses clocks
    */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Configure the Systick interrupt time
    */
  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

    /**Configure the Systick
    */
  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  /* SysTick_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}

/* ADC1 init function */
static void MX_ADC1_Init(void)
{

  ADC_MultiModeTypeDef multimode;
  ADC_ChannelConfTypeDef sConfig;

    /**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
    */
  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
  hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  hadc1.Init.ScanConvMode = DISABLE;
  hadc1.Init.ContinuousConvMode = ENABLE;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc1.Init.NbrOfConversion = 1;
  hadc1.Init.DMAContinuousRequests = ENABLE;
  hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Configure the ADC multi-mode
    */
  multimode.Mode = ADC_DUALMODE_REGSIMULT;
  multimode.DMAAccessMode = ADC_DMAACCESSMODE_2;
  multimode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_5CYCLES;
  if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
    */
  sConfig.Channel = ADC_CHANNEL_8;
  sConfig.Rank = 1;
  sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/* ADC2 init function */
static void MX_ADC2_Init(void)
{

  ADC_ChannelConfTypeDef sConfig;

    /**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
    */
  hadc2.Instance = ADC2;
  hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
  hadc2.Init.Resolution = ADC_RESOLUTION_12B;
  hadc2.Init.ScanConvMode = DISABLE;
  hadc2.Init.ContinuousConvMode = ENABLE;
  hadc2.Init.DiscontinuousConvMode = DISABLE;
  hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc2.Init.NbrOfConversion = 1;
  hadc2.Init.DMAContinuousRequests = ENABLE;
  hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  if (HAL_ADC_Init(&hadc2) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
    */
  sConfig.Channel = ADC_CHANNEL_9;
  sConfig.Rank = 1;
  sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
  if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/* I2C2 init function */
static void MX_I2C2_Init(void)
{

  hi2c2.Instance = I2C2;
  hi2c2.Init.ClockSpeed = 100000;
  hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c2.Init.OwnAddress1 = 0;
  hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c2.Init.OwnAddress2 = 0;
  hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c2) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/* SPI3 init function */
static void MX_SPI3_Init(void)
{

  hspi3.Instance = SPI3;
  hspi3.Init.Mode = SPI_MODE_MASTER;
  hspi3.Init.Direction = SPI_DIRECTION_2LINES;
  hspi3.Init.DataSize = SPI_DATASIZE_16BIT;
  hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi3.Init.NSS = SPI_NSS_SOFT;
  hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
  hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi3.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi3) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/* SPI6 init function */
static void MX_SPI6_Init(void)
{

  hspi6.Instance = SPI6;
  hspi6.Init.Mode = SPI_MODE_MASTER;
  hspi6.Init.Direction = SPI_DIRECTION_2LINES;
  hspi6.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi6.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi6.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi6.Init.NSS = SPI_NSS_SOFT;
  hspi6.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
  hspi6.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi6.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi6.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi6.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi6) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/* USART1 init function */
static void MX_USART1_UART_Init(void)
{

  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/* USART3 init function */
static void MX_USART3_UART_Init(void)
{

  huart3.Instance = USART3;
  huart3.Init.BaudRate = 115200;
  huart3.Init.WordLength = UART_WORDLENGTH_8B;
  huart3.Init.StopBits = UART_STOPBITS_1;
  huart3.Init.Parity = UART_PARITY_NONE;
  huart3.Init.Mode = UART_MODE_TX_RX;
  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart3) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

/**
  * Enable DMA controller clock
  */
static void MX_DMA_Init(void)
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA2_CLK_ENABLE();

  /* DMA interrupt init */
  /* DMA2_Stream0_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
  /* DMA2_Stream2_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn);
  /* DMA2_Stream5_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn);
  /* DMA2_Stream7_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Stream7_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream7_IRQn);

}

/** Configure pins as
        * Analog
        * Input
        * Output
        * EVENT_OUT
        * EXTI
     PB6   ------> I2C1_SCL
     PB7   ------> I2C1_SDA
*/
static void MX_GPIO_Init(void)
{

  GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOF_CLK_ENABLE();
  __HAL_RCC_GPIOH_CLK_ENABLE();
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
  __HAL_RCC_GPIOG_CLK_ENABLE();
  __HAL_RCC_GPIOE_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOF, UC_KICK_WDOG_Pin|CONTACT_QUALITY_MON_Pin|CH4_DAC_SPI3_CS_Pin|CH4_TEMP_SPI6_CS_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOC, CH4_RF_ENABLE_Pin|CH4_CAL_RELAY_CTL_Pin|CH4_RETURN_RELAY_CTL_Pin|STIM_SELECT_Pin
                          |DEBUG_OUTPUT_PC7_Pin|DEBUG_OUTPUT_PC8_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOG, CH3_RF_ENABLE_Pin|CH3_CAL_RELAY_CTL_Pin|CH1_DAC_SPI3_CS_Pin|CH1_TEMP_SPI6_CS_Pin
                          |STIM_NEG_Pin|STIM_POS_Pin|UC_WDOG_REG_DAT_Pin|UC_WDOG_REG_CLK_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOE, CH3_RETURN_RELAY_CTL_Pin|CH3_DAC_SPI3_CS_Pin|CH3_TEMP_SPI6_CS_Pin|CH2_RF_ENABLE_Pin
                          |CH2_CAL_RELAY_CTL_Pin|CH2_RETURN_RELAY_CTL_Pin|LED3_PE0_Pin|LED4_PE1_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOD, CH2_DAC_SPI3_CS_Pin|CH2_TEMP_SPI6_CS_Pin|CH1_RF_ENABLE_Pin|CH1_CAL_RELAY_CTL_Pin
                          |CH1_RETURN_RELAY_CTL_Pin|FAN_FLT_FULL_SPEED_Pin|OSC_460KHZ_ENABLE_Pin|L_UC_MASTER_DISABLE_RF_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pins : UC_KICK_WDOG_Pin CONTACT_QUALITY_MON_Pin CH4_DAC_SPI3_CS_Pin CH4_TEMP_SPI6_CS_Pin */
  GPIO_InitStruct.Pin = UC_KICK_WDOG_Pin|CONTACT_QUALITY_MON_Pin|CH4_DAC_SPI3_CS_Pin|CH4_TEMP_SPI6_CS_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

  /*Configure GPIO pins : CH4_TEMP_FAULT_Pin CH4_TEMP_DATA_READY_Pin CH3_TEMP_FAULT_Pin */
  GPIO_InitStruct.Pin = CH4_TEMP_FAULT_Pin|CH4_TEMP_DATA_READY_Pin|CH3_TEMP_FAULT_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

  /*Configure GPIO pins : CH4_RF_ENABLE_Pin CH4_CAL_RELAY_CTL_Pin CH4_RETURN_RELAY_CTL_Pin STIM_SELECT_Pin
                           DEBUG_OUTPUT_PC7_Pin DEBUG_OUTPUT_PC8_Pin */
  GPIO_InitStruct.Pin = CH4_RF_ENABLE_Pin|CH4_CAL_RELAY_CTL_Pin|CH4_RETURN_RELAY_CTL_Pin|STIM_SELECT_Pin
                          |DEBUG_OUTPUT_PC7_Pin|DEBUG_OUTPUT_PC8_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  /*Configure GPIO pin : FAN_TEMP_ALERT_Pin */
  GPIO_InitStruct.Pin = FAN_TEMP_ALERT_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(FAN_TEMP_ALERT_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : UC_WKUP_Pin */
  GPIO_InitStruct.Pin = UC_WKUP_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(UC_WKUP_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : CH3_RF_ENABLE_Pin CH3_CAL_RELAY_CTL_Pin CH1_DAC_SPI3_CS_Pin CH1_TEMP_SPI6_CS_Pin
                           STIM_NEG_Pin STIM_POS_Pin UC_WDOG_REG_DAT_Pin UC_WDOG_REG_CLK_Pin */
  GPIO_InitStruct.Pin = CH3_RF_ENABLE_Pin|CH3_CAL_RELAY_CTL_Pin|CH1_DAC_SPI3_CS_Pin|CH1_TEMP_SPI6_CS_Pin
                          |STIM_NEG_Pin|STIM_POS_Pin|UC_WDOG_REG_DAT_Pin|UC_WDOG_REG_CLK_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

  /*Configure GPIO pins : CH3_RETURN_RELAY_CTL_Pin CH3_DAC_SPI3_CS_Pin CH3_TEMP_SPI6_CS_Pin CH2_RF_ENABLE_Pin
                           CH2_CAL_RELAY_CTL_Pin CH2_RETURN_RELAY_CTL_Pin LED3_PE0_Pin LED4_PE1_Pin */
  GPIO_InitStruct.Pin = CH3_RETURN_RELAY_CTL_Pin|CH3_DAC_SPI3_CS_Pin|CH3_TEMP_SPI6_CS_Pin|CH2_RF_ENABLE_Pin
                          |CH2_CAL_RELAY_CTL_Pin|CH2_RETURN_RELAY_CTL_Pin|LED3_PE0_Pin|LED4_PE1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

  /*Configure GPIO pins : CH3_TEMP_DATA_READY_Pin CH2_TEMP_FAULT_Pin */
  GPIO_InitStruct.Pin = CH3_TEMP_DATA_READY_Pin|CH2_TEMP_FAULT_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

  /*Configure GPIO pins : CH2_TEMP_DATA_READY_Pin CH1_TEMP_FAULT_Pin H_LOCKOUT_RF_MONITOR_Pin L_STANDBY_ACTIVE_1_Pin */
  GPIO_InitStruct.Pin = CH2_TEMP_DATA_READY_Pin|CH1_TEMP_FAULT_Pin|H_LOCKOUT_RF_MONITOR_Pin|L_STANDBY_ACTIVE_1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

  /*Configure GPIO pins : CH2_DAC_SPI3_CS_Pin CH2_TEMP_SPI6_CS_Pin CH1_RF_ENABLE_Pin CH1_CAL_RELAY_CTL_Pin
                           CH1_RETURN_RELAY_CTL_Pin FAN_FLT_FULL_SPEED_Pin L_UC_MASTER_DISABLE_RF_Pin */
  GPIO_InitStruct.Pin = CH2_DAC_SPI3_CS_Pin|CH2_TEMP_SPI6_CS_Pin|CH1_RF_ENABLE_Pin|CH1_CAL_RELAY_CTL_Pin
                          |CH1_RETURN_RELAY_CTL_Pin|FAN_FLT_FULL_SPEED_Pin|L_UC_MASTER_DISABLE_RF_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

  /*Configure GPIO pin : CH1_TEMP_DATA_READY_Pin */
  GPIO_InitStruct.Pin = CH1_TEMP_DATA_READY_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(CH1_TEMP_DATA_READY_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : DEBUG_INPUT_PC9_Pin */
  GPIO_InitStruct.Pin = DEBUG_INPUT_PC9_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(DEBUG_INPUT_PC9_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : OSC_460KHZ_ENABLE_Pin */
  GPIO_InitStruct.Pin = OSC_460KHZ_ENABLE_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(OSC_460KHZ_ENABLE_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : FAN_OVERTEMP_Pin */
  GPIO_InitStruct.Pin = FAN_OVERTEMP_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(FAN_OVERTEMP_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pin : L_WDOG_TIMER_EXPIRED_Pin */
  GPIO_InitStruct.Pin = L_WDOG_TIMER_EXPIRED_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(L_WDOG_TIMER_EXPIRED_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : UC_I2C1_CLK_FUTURE_IO_Pin UC_I2C1_DAT_FUTURE_IO_Pin */
  GPIO_InitStruct.Pin = UC_I2C1_CLK_FUTURE_IO_Pin|UC_I2C1_DAT_FUTURE_IO_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @param  None
  * @retval None
  */
void _Error_Handler(char * file, int line)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  while(1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef USE_FULL_ASSERT

/**
   * @brief Reports the name of the source file and the source line number
   * where the assert_param error has occurred.
   * @param file: pointer to the source file name
   * @param line: assert_param error line source number
   * @retval None
   */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */

}

#endif

/**
  * @}
  */

/**
  * @}
*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

Attachments

Outcomes