首頁 > 評測 > 【NUCLEO-U575ZI-Q測評】DAC測試
【NUCLEO-U575ZI-Q測評】DAC測試
- [導讀]
- 本帖最后由 dql2015 于 2023-3-24 16:26 編輯 STM32U5的DAC支持正常模式和采樣保持模式,其中采樣保持模式用于低功耗狀態(tài)使用,每路 DAC 輸出均可與 DAC_OUTx 輸出引腳斷開連接,而且 DAC 輸出可與片上外設連
本帖最后由 dql2015 于 2023-3-24 16:26 編輯
STM32U5的DAC支持正常模式和采樣保持模式,其中采樣保持模式用于低功耗狀態(tài)使用,每路 DAC 輸出均可與 DAC_OUTx 輸出引腳斷開連接,而且 DAC 輸出可與片上外設連接。一般情況下,使用出廠校準即可,芯片上電后自動完成出廠校準。STM32U5內(nèi)置了高性能帶PGA功能的運算放大器,可以通過配置形成多種常用模擬信號處理電路:
配置電壓跟隨器的用法:
DAC外設配置:
運放配置,將DAC輸出連接到運放輸入:
正弦輸出表:
- uint32_t Wave_LUT[128] = {
- 2048, 2149, 2250, 2350, 2450, 2549, 2646, 2742, 2837, 2929, 3020, 3108, 3193, 3275, 3355,
- 3431, 3504, 3574, 3639, 3701, 3759, 3812, 3861, 3906, 3946, 3982, 4013, 4039, 4060, 4076,
- 4087, 4094, 4095, 4091, 4082, 4069, 4050, 4026, 3998, 3965, 3927, 3884, 3837, 3786, 3730,
- 3671, 3607, 3539, 3468, 3394, 3316, 3235, 3151, 3064, 2975, 2883, 2790, 2695, 2598, 2500,
- 2400, 2300, 2199, 2098, 1997, 1896, 1795, 1695, 1595, 1497, 1400, 1305, 1212, 1120, 1031,
- 944, 860, 779, 701, 627, 556, 488, 424, 365, 309, 258, 211, 168, 130, 97,
- 69, 45, 26, 13, 4, 0, 1, 8, 19, 35, 56, 82, 113, 149, 189,
- 234, 283, 336, 394, 456, 521, 591, 664, 740, 820, 902, 987, 1075, 1166, 1258,
- 1353, 1449, 1546, 1645, 1745, 1845, 1946, 2047
- };
開啟運放
- HAL_OPAMP_Start(&hopamp1);
開啟DAC
- HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
設置DAC輸出值
- HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, Wave_LUT[i]);
完整代碼如下:
- /* USER CODE BEGIN Header */
- /**
- ******************************************************************************
- * [url=home.php?mod=space&uid=288409]@file[/url] : main.c
- * [url=home.php?mod=space&uid=247401]@brief[/url] : Main program body
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
- /* USER CODE END Header */
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- #include "adc.h"
- #include "dac.h"
- #include "opamp.h"
- #include "ucpd.h"
- #include "usart.h"
- #include "usb_otg.h"
- #include "gpio.h"
- /* Private includes ----------------------------------------------------------*/
- /* USER CODE BEGIN Includes */
- #include <stdio.h>
- /* USER CODE END Includes */
- /* Private typedef -----------------------------------------------------------*/
- /* USER CODE BEGIN PTD */
- /* USER CODE END PTD */
- /* Private define ------------------------------------------------------------*/
- /* USER CODE BEGIN PD */
- /* USER CODE END PD */
- /* Private macro -------------------------------------------------------------*/
- /* USER CODE BEGIN PM */
- /* USER CODE END PM */
- /* Private variables ---------------------------------------------------------*/
- /* USER CODE BEGIN PV */
- uint32_t Wave_LUT[128] = {
- 2048, 2149, 2250, 2350, 2450, 2549, 2646, 2742, 2837, 2929, 3020, 3108, 3193, 3275, 3355,
- 3431, 3504, 3574, 3639, 3701, 3759, 3812, 3861, 3906, 3946, 3982, 4013, 4039, 4060, 4076,
- 4087, 4094, 4095, 4091, 4082, 4069, 4050, 4026, 3998, 3965, 3927, 3884, 3837, 3786, 3730,
- 3671, 3607, 3539, 3468, 3394, 3316, 3235, 3151, 3064, 2975, 2883, 2790, 2695, 2598, 2500,
- 2400, 2300, 2199, 2098, 1997, 1896, 1795, 1695, 1595, 1497, 1400, 1305, 1212, 1120, 1031,
- 944, 860, 779, 701, 627, 556, 488, 424, 365, 309, 258, 211, 168, 130, 97,
- 69, 45, 26, 13, 4, 0, 1, 8, 19, 35, 56, 82, 113, 149, 189,
- 234, 283, 336, 394, 456, 521, 591, 664, 740, 820, 902, 987, 1075, 1166, 1258,
- 1353, 1449, 1546, 1645, 1745, 1845, 1946, 2047
- };
- /* USER CODE END PV */
- /* Private function prototypes -----------------------------------------------*/
- void SystemClock_Config(void);
- static void SystemPower_Config(void);
- /* USER CODE BEGIN PFP */
- /* USER CODE END PFP */
- /* Private user code ---------------------------------------------------------*/
- /* USER CODE BEGIN 0 */
- /* USER CODE END 0 */
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] The application entry point.
- * @retval int
- */
- 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();
- /* Configure the System Power */
- SystemPower_Config();
- /* USER CODE BEGIN SysInit */
- /* USER CODE END SysInit */
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- MX_UCPD1_Init();
- MX_USART1_UART_Init();
- MX_USB_OTG_FS_PCD_Init();
- MX_ADC1_Init();
- MX_OPAMP1_Init();
- MX_DAC1_Init();
- /* USER CODE BEGIN 2 */
在實際應用中采用定時器定時觸發(fā)+DMA傳輸更實用。
- 本文系21ic原創(chuàng),未經(jīng)許可禁止轉(zhuǎn)載!
網(wǎng)友評論
- 聯(lián)系人:巧克力娃娃
- 郵箱:board@21ic.com
- 我要投稿
-
歡迎入駐,開放投稿
-
人均百萬?英偉達中國員工收入曝光! 2024-08-29
-
《黑神話:悟空》玩家硬盤升級攻略:提升游戲體驗,暢享3A大作 2024-08-29
-
數(shù)睿數(shù)據(jù)參加《系統(tǒng)與軟件工程 低代碼開發(fā)平臺通用技術要求》國家標準編制 2024-08-29
- NRF52810藍牙數(shù)字耳機找人定制
預算:¥30005天前
- 125KW模塊式PCS軟硬件外包開發(fā)
預算:¥1100000015小時前
- 12V汽車啟動電源項目BMS設計
預算:¥50000023小時前
- 數(shù)據(jù)可視化軟件 開發(fā)
預算:¥5000023小時前
- PLC項目調(diào)試修改
預算:¥100001天前
- 起動電機控制器開發(fā)
預算:¥1100001天前