完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
%% 清内存 关闭窗口 准备工作 clear close all clc t=-0:pi*2/399:2*pi; %离散时间t s1=ceil((4096/2-1)*sin(0:pi*2/399:2*pi)+2048) %正弦信号 figure(1) plot(t,s1); xlabel('时间/s'); ylabel('幅度'); t为时间取样值 s1是产生的离散正弦数码 我用的stm32自带的DAC是12位的,最大能转换的数字值为2^12=4096,所以我们需要得到的数字为0~4096 所以振幅设置成了4096/2-1,打点从0到2π中间打400个点 因为单片机不能转换负压,所以加一个2048(电压一般)的电压偏置。 matlab图形:
在matlab工作区,双击上图蓝色字: 点右键转置变量 将数据复制到excel中:
=DEC2HEX(A1) A1为被转换数据列
C1为被转换数据列
const uint16_t Sine400bit[400]={ 0x0800,0x0821,0x0841,0x0861,0x0881,0x08A2,0x08C2,0x08E2,0x0902,0x0922, 0x0942,0x0961,0x0981,0x09A1,0x09C0,0x09E0,0x09FF,0x0A1E,0x0A3D,0x0A5C, 0x0A7B,0x0A99,0x0AB8,0x0AD6,0x0AF4,0x0B12,0x0B2F,0x0B4D,0x0B6A,0x0B87, 0x0BA4,0x0BC1,0x0BDD,0x0BF9,0x0C15,0x0C30,0x0C4C,0x0C67,0x0C82,0x0C9C, 0x0CB6,0x0CD0,0x0CEA,0x0D03,0x0D1C,0x0D35,0x0D4D,0x0D65,0x0D7D,0x0D94, 0x0DAB,0x0DC1,0x0DD8,0x0DED,0x0E03,0x0E18,0x0E2D,0x0E41,0x0E55,0x0E68, 0x0E7B,0x0E8E,0x0EA0,0x0EB2,0x0EC4,0x0ED5,0x0EE5,0x0EF5,0x0F05,0x0F14, 0x0F23,0x0F31,0x0F3F,0x0F4D,0x0F5A,0x0F66,0x0F72,0x0F7E,0x0F89,0x0F93, 0x0F9D,0x0FA7,0x0FB0,0x0FB9,0x0FC1,0x0FC9,0x0FD0,0x0FD6,0x0FDD,0x0FE2, 0x0FE7,0x0FEC,0x0FF0,0x0FF4,0x0FF7,0x0FFA,0x0FFC,0x0FFE,0x0FFF,0x0FFF, 0x0FFF,0x0FFF,0x0FFE,0x0FFD,0x0FFB,0x0FF9,0x0FF6,0x0FF2,0x0FEE,0x0FEA, 0x0FE5,0x0FDF,0x0FDA,0x0FD3,0x0FCC,0x0FC5,0x0FBD,0x0FB4,0x0FAC,0x0FA2, 0x0F98,0x0F8E,0x0F83,0x0F78,0x0F6C,0x0F60,0x0F53,0x0F46,0x0F38,0x0F2A, 0x0F1C,0x0F0D,0x0EFD,0x0EED,0x0EDD,0x0ECC,0x0EBB,0x0EA9,0x0E97,0x0E85, 0x0E72,0x0E5F,0x0E4B,0x0E37,0x0E22,0x0E0D,0x0DF8,0x0DE3,0x0DCD,0x0DB6, 0x0D9F,0x0D88,0x0D71,0x0D59,0x0D41,0x0D28,0x0D10,0x0CF6,0x0CDD,0x0CC3, 0x0CA9,0x0C8F,0x0C74,0x0C59,0x0C3E,0x0C23,0x0C07,0x0BEB,0x0BCF,0x0BB2, 0x0B96,0x0B79,0x0B5C,0x0B3E,0x0B21,0x0B03,0x0AE5,0x0AC7,0x0AA8,0x0A8A, 0x0A6B,0x0A4C,0x0A2D,0x0A0E,0x09EF,0x09D0,0x09B0,0x0991,0x0971,0x0951, 0x0932,0x0912,0x08F2,0x08D2,0x08B2,0x0891,0x0871,0x0851,0x0831,0x0811, 0x07F0,0x07D0,0x07B0,0x0790,0x0770,0x074F,0x072F,0x070F,0x06EF,0x06CF, 0x06B0,0x0690,0x0670,0x0651,0x0631,0x0612,0x05F3,0x05D4,0x05B5,0x0596, 0x0577,0x0559,0x053A,0x051C,0x04FE,0x04E0,0x04C3,0x04A5,0x0488,0x046B, 0x044F,0x0432,0x0416,0x03FA,0x03DE,0x03C3,0x03A8,0x038D,0x0372,0x0358, 0x033E,0x0324,0x030B,0x02F1,0x02D9,0x02C0,0x02A8,0x0290,0x0279,0x0262, 0x024B,0x0234,0x021E,0x0209,0x01F4,0x01DF,0x01CA,0x01B6,0x01A2,0x018F, 0x017C,0x016A,0x0158,0x0146,0x0135,0x0124,0x0114,0x0104,0x00F4,0x00E5, 0x00D7,0x00C9,0x00BB,0x00AE,0x00A1,0x0095,0x0089,0x007E,0x0073,0x0069, 0x005F,0x0055,0x004D,0x0044,0x003C,0x0035,0x002E,0x0027,0x0022,0x001C, 0x0017,0x0013,0x000F,0x000B,0x0008,0x0006,0x0004,0x0003,0x0002,0x0002, 0x0002,0x0002,0x0003,0x0005,0x0007,0x000A,0x000D,0x0011,0x0015,0x001A, 0x001F,0x0024,0x002B,0x0031,0x0038,0x0040,0x0048,0x0051,0x005A,0x0064, 0x006E,0x0078,0x0083,0x008F,0x009B,0x00A7,0x00B4,0x00C2,0x00D0,0x00DE, 0x00ED,0x00FC,0x010C,0x011C,0x012C,0x013D,0x014F,0x0161,0x0173,0x0186, 0x0199,0x01AC,0x01C0,0x01D4,0x01E9,0x01FE,0x0214,0x0229,0x0240,0x0256, 0x026D,0x0284,0x029C,0x02B4,0x02CC,0x02E5,0x02FE,0x0317,0x0331,0x034B, 0x0365,0x037F,0x039A,0x03B5,0x03D1,0x03EC,0x0408,0x0424,0x0440,0x045D, 0x047A,0x0497,0x04B4,0x04D2,0x04EF,0x050D,0x052B,0x0549,0x0568,0x0586, 0x05A5,0x05C4,0x05E3,0x0602,0x0621,0x0641,0x0660,0x0680,0x06A0,0x06BF, 0x06DF,0x06FF,0x071F,0x073F,0x075F,0x0780,0x07A0,0x07C0,0x07E0,0x0800, }; |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1802 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1629 浏览 1 评论
1096 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
735 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1685 浏览 2 评论
1944浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
747浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
580浏览 3评论
602浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
565浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 05:54 , Processed in 0.675435 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号