【iCore4 双核心板_ARM】例程三十六:DAC实验——输出直流电压

实验现象:

用电压表测量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链接:

posted @ 2017-09-30 10:45  XiaomaGee  阅读(558)  评论(0编辑  收藏  举报