【国民技术M4内核热销款N32G45XVL评估】第三篇 DAC输出双路三角波信号
[复制链接]
春节假期里找了点时间搞一下板子。
看了下DAC模块的使用,做了一个使用DAC输出双路三角波信号的例子。
下面就直接上代码和波形图了。
- GPIO_InitType GPIO_InitStructure;
-
- SetSysClockToPLL(144000000, SYSCLK_PLLSRC_HSE);
-
- /* Once the DAC channel is enabled, the corresponding GPIO pin is automatically
- connected to the DAC converter. In order to avoid parasitic consumption,
- the GPIO pin should be configured in analog */
-
- /* GPIOA Periph clock enable */
- RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
- /* Once the DAC channel is enabled, the corresponding GPIO pin is automatically
- connected to the DAC converter. In order to avoid parasitic consumption,
- the GPIO pin should be configured in analog */
- GPIO_InitStructure.Pin = GPIO_PIN_4 | GPIO_PIN_5;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
- GPIO_InitPeripheral(GPIOA, &GPIO_InitStructure);
-
- RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_DAC, ENABLE);
- DAC->CTRL = 0x0FBF0FBF;
- DAC->CTRL = 0x0FBF0FBF;
- DAC->SOTTR = 0X3;
- DAC->DR12DCH = 0;//500<<16 | 500;
-
- while (1)
- {
- DAC->SOTTR = 0X3;
- }
|