Skip to main content
PGood.1
Associate III
December 14, 2021
Question

DAC restricted to 0.5volt on a stm32L432 when you add a gpio_output to any PB

  • December 14, 2021
  • 2 replies
  • 2767 views

DAC restricted to 0.5volt on a stm32L432 when you add a gpio_output to any PB and appears to be the line __HAL_RCC_GPIOB_CLK_ENABLE(); added to MX_GPIO_Init

with

static void MX_GPIO_Init(void)

{

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* GPIO Ports Clock Enable */

 __HAL_RCC_GPIOA_CLK_ENABLE();

 //__HAL_RCC_GPIOB_CLK_ENABLE();

0693W00000HobhtQAB.png 

void MX_GPIO_Init(void)

{

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* GPIO Ports Clock Enable */

 __HAL_RCC_GPIOA_CLK_ENABLE();

 __HAL_RCC_GPIOB_CLK_ENABLE();

0693W00000HobirQAB.png

This topic has been closed for replies.

2 replies

PGood.1
PGood.1Author
Associate III
December 14, 2021

/* USER CODE BEGIN PFP */

uint32_t wave_time;

uint16_t sinwavevalue ;

uint16_t coswavevalue;

uint16_t sinwave[20] ={2681,3252,3705,3996,4095,3996,3705,3252,2681,2048,1415,844,391,100,0,100,391,844,1415,2048};

uint16_t coswave[20] ={3996,3705,3252,2681,2048,1415,844,391,100,0,100,391,844,1415,2048,2681,3252,3705,3996,4095};

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/

/* USER CODE BEGIN 0 */

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef * htim) {

 if (htim -> Instance == TIM15) {

    sinwavevalue=sinwave[wave_time];

    coswavevalue=coswave[wave_time];

     HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, sinwavevalue);

     HAL_DAC_Start(&hdac1,DAC_CHANNEL_1);

     HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_2, DAC_ALIGN_12B_R, coswavevalue);

     HAL_DAC_Start(&hdac1,DAC_CHANNEL_2);

     wave_time++;

     if (wave_time==20) wave_time=0;

 }

}

/* USER CODE END 0 */

waclawek.jan
Super User
December 14, 2021

What hardware is this, a "known good" board such as Nucleo or Disco, or your own? Do you measure "Channel1" on PA5 or on some other pin? What else is connected to that pin?

JW

Tesla DeLorean
Guru
December 14, 2021

>>What else is connected to that pin?

Or anything else on GPIO BANK B.

Check for inter-connnects, shorts. Netlist?

uint32_t wave_time; // global or auto/local ?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..