cancel
Showing results for 
Search instead for 
Did you mean: 

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

PGood.1
Associate II

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

4 REPLIES 4
PGood.1
Associate II

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

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

>>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 Venmo
Up vote any posts that you find helpful, it shows what's working..

From the old unrelated thread.

https://community.st.com/s/question/0D53W00000Po8KSSAZ/stm32f20x-adc-has-voltage-output

"Having a look at the schematic it looks like there are 2 jumpers on the back of the board SB18 Connect D4 to A4 and SB16 Connect D5 to A5 if you want to use A4 (PA5) as an analogue output or a5 as an ADC these jumpers need to be removed"

Signs point to a NUCLEO-32 board with L432

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