STM32 Family DAC Triangle Wave Generation on mbed

The documentation states that “The STM32 DAC provides the user with a triangular waveform generator with a flexible offset, amplitude and frequency.” How would I utilize this in mbed? I have a STM Nucleo F303K8 board.

Hello Miraç,

Build the triangle wave generator with the STM32CubeIDE.

Make sure:

  • You use the same clock configuration for the NUCLEO-F303K8 as defined by Mbed in the mbed-os/targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/TARGET_NUCLEO_F303K8/system_clock.c file.
  • You don’t use the Timer used by Mbed for us_ticker. Check in the `mbed-os/targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303x8/device/us_ticker_data.h’ file. (For the NUCLEO-F303K8 it’s timer TIM2.)

When you are happy with the performance move your project to Mbed :

  • Create a new program for the NUCLEO-F303K8 in the Mbed Online Compiler by selecting a mbed os blinky template.
  • Replace the main.cpp with the main.c content of the STM32CubeIDE project.
  • Comment out (or delete) the HAL_Init() and SystemClock_Config() functions.
  • Copy & Paste the other files with codes from the STM32CubeIDE project to the online compiler project.
  • Rename and modify:\
    “stm32f4xx_it.h” to “stm32f4xx_it_msp.h”\
    “stm32f4xx_it.c” to “stm32f4xx_it_msp.c”
  • Add additional features to the program as needed.

I used the same method to build the following programs:

3.5" inch TFT LCD Display Module 480X320 driven with FSMC

Barcode reader with NUCLEO_F103RB

Reading internal temperature of NUCLEO_F103RB chip

Best regards,

Zoltan

2 Likes

Thank you for the reply! I will try and implement this.