ECE471/571 (RTOS) STM32 C Example - DAC used directly

In STM32CubeMX

  1. Initialize all peripherals with in default mode? - yes
  2. find PB0, PB7, PB14, PC13
  3. find DAC
  4. enable UART3
  5. disable Ethernet (optional)
  6. disable USB_OTG_FS (optional)

Adapt and compile a project (example 1)

  1. Open source/main.c
  2. Locate int main() function
  3. Inspect the GPIO initialization called from main()
  4. Locate the DAC initialization in main()
  5. Insert your code ** HERE **
      MX_DAC_Init();
      /* USER CODE BEGIN 2 */
          ** HERE **
      /* USER CODE END 2 */
    
  6. Code for starting the timer and enabling timer interrupt
      HAL_DAC_Init(&hdac);
      HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
    
  7. Locate the forever loop in main()
  8. Insert your code ** HERE **
        /* USER CODE BEGIN WHILE */
        while (1)
        {
        /* USER CODE END WHILE */
    
        /* USER CODE BEGIN 3 */
            ** HERE **
        }
        /* USER CODE END 3 */
    
  9. Code for ** HERE **
        for(uint32_t val = 0 ; val*lt;4096; val++) {
          HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, val);
          HAL_Delay(1);
        }
        for(uint32_t val = 4094 ; val>00; val--) {
          HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, val);
          HAL_Delay(1);
        }
    
    

web site front local main page local list page general bookmarks software bookmarks go back copyright info