Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
DAC
RA8-M85-vision-board
【Vision Board 创客营】Vision Board上的DAC实践
发布于 2024-04-24 21:51:18 浏览:206
订阅该版
[tocm] ### 1、概述 感谢官方举办【Vision Board 创客营】活动,使得我有机会试用Vision Board开发板,体验嵌入式AI的快乐。在此,再次感谢官方以及导师们的热情帮助。在本次活动中,本人选择的是DAC功能的测试。 ### 2、环境配置 ##### 配置 系统:Win11 开发板:RA8-M85-vision-board 开发IDE:RTThread Studio 版本: 2.2.6 ##### 环境配置 - 下载[开发所需软件资料](https://pan.baidu.com/s/1O38xjFGV2K1RP7tP1WlcvA?pwd=ra8v) - 根据官方提供的[文档]( [Vision Board 环境搭建 (qq.com)](https://docs.qq.com/doc/DY2hkbVdiSGV1S3JM) )搭建开发环境 ### 3、新建工程以及编写测试例程 1. 新建工程 - 打开RTThread Studio IDE ,选择文件 --> 新建 --> RT-Thread 项目 - 输入工程信息,可参考下图: ![创建工程.png](https://oss-club.rt-thread.org/uploads/20240424/3ee6415fabc4c61cce89a8f67b37682d.png.webp) - 使能DAC驱动框架,可参考下图: ![配置驱动1.png](https://oss-club.rt-thread.org/uploads/20240424/88ba2fdd1ebd726b05dd502c3643a834.png) ![配置驱动2.png](https://oss-club.rt-thread.org/uploads/20240424/c1cc8f638ff9e7c307643d997e477b3c.png.webp) - 打开RA Smart Configurator (记得选择sc_v2023-10_fsp_v5.1.0 文件夹),进行DAC硬件功能配置,具体可参考下图: ![引脚功能配置1.png](https://oss-club.rt-thread.org/uploads/20240424/dbf0330e097162594348253c8747111c.png.webp) ![引脚功能配置2.png](https://oss-club.rt-thread.org/uploads/20240424/7c10fcc8a38e13e6c28366de0b1451a8.png.webp) ![引脚功能配置3.png](https://oss-club.rt-thread.org/uploads/20240424/a2389c17a10a9a1d62f2eaf572201dc4.png.webp) 2. 测试程序 - 在工程src目录中,右键新建 test_dac.c 文件,文件内容如下: ```c /** 功能说明:通过DAC生成一个正弦波,其中每一个dac的输出值,是通过py程序自动生成,可在附录中自取 */ /* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2024-04-20 MagicKingC the first version */ #include
#include
#define DAC_DEV_NAME "dac0" #define DAC_DEV_CHANNEL 0 static rt_uint32_t sin_wave_vaule[]={ 2048,2073,2098,2123,2149,2174,2199,2224,2249,2274, 2299,2324,2349,2374,2399,2423,2448,2473,2497,2522, 2546,2571,2595,2619,2643,2667,2691,2715,2739,2763, 2786,2810,2833,2856,2879,2902,2925,2947,2970,2992, 3015,3037,3059,3081,3102,3124,3145,3166,3187,3208, 3229,3249,3269,3290,3309,3329,3349,3368,3387,3406, 3425,3443,3462,3480,3498,3515,3533,3550,3567,3584, 3600,3617,3633,3648,3664,3679,3694,3709,3724,3738, 3752,3766,3780,3793,3806,3819,3831,3843,3855,3867, 3878,3890,3900,3911,3921,3931,3941,3950,3960,3968, 3977,3985,3993,4001,4008,4015,4022,4029,4035,4041, 4046,4052,4057,4061,4066,4070,4074,4077,4080,4083, 4086,4088,4090,4092,4093,4094,4095,4095,4095,4095, 4094,4093,4092,4091,4089,4087,4084,4082,4079,4075, 4072,4068,4064,4059,4054,4049,4044,4038,4032,4026, 4019,4012,4005,3997,3989,3981,3973,3964,3955,3946, 3936,3926,3916,3906,3895,3884,3873,3861,3849,3837, 3825,3812,3799,3786,3773,3759,3745,3731,3717,3702, 3687,3672,3656,3641,3625,3608,3592,3575,3559,3541, 3524,3507,3489,3471,3453,3434,3416,3397,3378,3358, 3339,3319,3300,3280,3259,3239,3218,3198,3177,3156, 3134,3113,3091,3070,3048,3026,3004,2981,2959,2936, 2913,2891,2868,2844,2821,2798,2774,2751,2727,2703, 2679,2655,2631,2607,2583,2559,2534,2510,2485,2460, 2436,2411,2386,2361,2336,2312,2287,2262,2237,2211, 2186,2161,2136,2111,2086,2061,2035,2010,1985,1960, 1935,1910,1885,1859,1834,1809,1784,1760,1735,1710, 1685,1660,1636,1611,1586,1562,1537,1513,1489,1465, 1441,1417,1393,1369,1345,1322,1298,1275,1252,1228, 1205,1183,1160,1137,1115,1092,1070,1048,1026,1005, 983,962,940,919,898,878,857,837,816,796, 777,757,738,718,699,680,662,643,625,607, 589,572,555,537,521,504,488,471,455,440, 424,409,394,379,365,351,337,323,310,297, 284,271,259,247,235,223,212,201,190,180, 170,160,150,141,132,123,115,107,99,91, 84,77,70,64,58,52,47,42,37,32, 28,24,21,17,14,12,9,7,5,4, 3,2,1,1,1,1,2,3,4,6, 8,10,13,16,19,22,26,30,35,39, 44,50,55,61,67,74,81,88,95,103, 111,119,128,136,146,155,165,175,185,196, 206,218,229,241,253,265,277,290,303,316, 330,344,358,372,387,402,417,432,448,463, 479,496,512,529,546,563,581,598,616,634, 653,671,690,709,728,747,767,787,806,827, 847,867,888,909,930,951,972,994,1015,1037, 1059,1081,1104,1126,1149,1171,1194,1217,1240,1263, 1286,1310,1333,1357,1381,1405,1429,1453,1477,1501, 1525,1550,1574,1599,1623,1648,1673,1697,1722,1747, 1772,1797,1822,1847,1872,1897,1922,1947,1973,1998, 2023,2048 }; /** * 通过dac生成sin波形 * @param agrc * @param agrv * @return */ static int sin_dac_sample(int agrc, char **agrv){ rt_dac_device_t dac_dev; //打开硬件外设 dac_dev = (rt_dac_device_t)rt_device_find(DAC_DEV_NAME); if (dac_dev == RT_NULL) { rt_kprintf("can't find %s device\r\n",DAC_DEV_NAME); return -RT_ERROR; } rt_dac_enable(dac_dev, DAC_DEV_CHANNEL); rt_kprintf("begin echo sin wave\r\n"); for (int i = 0; i < 300; ++i) { for (int j = 0; j < sizeof(sin_wave_vaule)/sizeof(rt_uint32_t); ++j) { rt_dac_write(dac_dev, DAC_DEV_CHANNEL, sin_wave_vaule[j]); rt_thread_mdelay(1); } } rt_kprintf("end echo sin wave\r\n"); return 0; } MSH_CMD_EXPORT(sin_dac_sample,dac out sin wave sample) ``` - 进行程序编译,然后烧录到开发板 ### 4、测试 1. 打开串口工具输入 ,在finsh 命令行中输入 sin_dac_sample ,然后回车,现象可看下图: ![测试图.png](https://oss-club.rt-thread.org/uploads/20240424/4c9fbc965b9a858e25deca4693f43ba0.png) ![000.BMP](https://oss-club.rt-thread.org/uploads/20240424/16c7f7e36a834dcda9f0f9b09eb4a91c.bmp) 到此测试完毕 ### 5、总结 到此 DAC 测试已经完毕,感觉在本次测试下来的很顺利,开发速度非常块,需要简单的几个配置,就可以将DAC使用起来。 ### 附录 sin.py ```python import numpy as np import matplotlib.pyplot as plt t = np.linspace(0,1,512) y = (np.sin(2*np.pi*t) * 2047) + 2048 count = 0 for num in np.round(y): print("%d" % num, end=',') count = count +1 if count % 10 == 0: print() plt.scatter(t,y) plt.show() ```
0
条评论
默认排序
按发布时间排序
登录
注册新账号
关于作者
MagicKingC
板凳打酱油
文章
3
回答
0
被采纳
0
关注TA
发私信
相关文章
1
dac设备可以使用dma+TIM定时器触发模式吗
2
无法找到rt_dac_device_t
3
stm32的dac配置,指南里面没有
4
在 rt-thraed env中使用HAL库报错HAL_BUSY
5
STM32F103RC dac输出使能后系统调度异常。
6
怎么把dac_vol_sample这个函数写到main里?
7
undeclared (first use in this function)
8
DAC通道1可以开启,通道2开不起来
9
DAC、ADC配置DMA后,程序运行卡死
10
在RT模式下,采用DMA模式如何设置DAC?
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
UART
ota在线升级
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
msh
SFUD
keil_MDK
rt_mq_消息队列_msg_queue
ulog
C++_cpp
at_device
本月问答贡献
踩姑娘的小蘑菇
7
个答案
3
次被采纳
a1012112796
13
个答案
2
次被采纳
张世争
9
个答案
2
次被采纳
rv666
5
个答案
2
次被采纳
用户名由3_15位
11
个答案
1
次被采纳
本月文章贡献
程序员阿伟
9
篇文章
2
次点赞
hhart
3
篇文章
4
次点赞
大龄码农
1
篇文章
5
次点赞
RTT_逍遥
1
篇文章
2
次点赞
ThinkCode
1
篇文章
1
次点赞
回到
顶部
发布
问题
投诉
建议
回到
底部