【iCore4 雙核心板_ARM】例程三十六:DAC實驗——輸出直流電壓

XiaomaGee發表於2017-09-30

實驗現象:

用電壓表測量PA4引腳有2.0V直流電壓輸出。

核心程式碼:

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DAC_Init();

  /* USER CODE BEGIN 2 */
    LED_GREEN_ON;
    HAL_DAC_Start(&hdac, DAC_CHANNEL_1); //¿ªÆôDACͨµÀ1
    dac1.set_voltage(2.0);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}

原始碼下載連結:

連結:http://pan.baidu.com/s/1dFD4z09 密碼:m711

iCore4連結:

相關文章