STM32CubeMX create engineering dual DAC waveform output

STM32Cube software to generate initialization code, HAl firmware library greatly reduce the code to work. Also dual DAC output waveform at the plate STM32F103


After generating keil inside the project, add the main program in the main

  /* USER CODE BEGIN 2 */

  
    HAL_TIM_Base_Start(&htim6);
    HAL_DAC_Start_DMA(&hdac, DAC_CHANNEL_1, (uint32_t *)sine_wave, 1000, DAC_ALIGN_12B_R);
    HAL_DAC_Start_DMA(&hdac, DAC_CHANNEL_2, (uint32_t *)sine_wave, 1000, DAC_ALIGN_12B_R);

/* USER CODE END 2 */

2 can output a sinusoidal path

Note that, when defining the pin SYS way to select the right download. I swd jlink mode, if no election-wire serial port, for the first time in keil download code to the chip will lock the chip, resulting in chip ID can not be read again, you can not then download the program. Estimated to be two to download pin is set to other modes of communication can not do swd. Once locked, the solution is to BOOT0 pin to the pull, the power to enter the bootloader, and then download a normal procedure

Further, the development of three programming stm32 own characteristics. Direct register read and write, simple and direct, fast compiler, high efficiency, but require more familiar with the hardware, or have knowledge of the microcontroller; traditional library firmware is currently 3.5 and 4.0, just call the rich programming library functions, reducing the workload, there are many references, but felt a little clumsy, the official seems to have no further maintained; sampling cubemx can complete graphical programming in the most troublesome part of the initialization, using the firmware library hal completed application programming part, generally a combination of front the advantages of the two methods, the biggest advantage is easier to transplant, but the compiler slow, not good control over the details. Three methods have their advantages, the moment hal firmware library programming is a trend. But most simple uncomplicated development, individuals still feel the most appropriate direct read and write registers.

Guess you like

Origin blog.csdn.net/mcubbs/article/details/53875301