找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4231|回复: 1
收起左侧

c51单片机的TLC5615 10Bit DA正弦信号发生器程序+仿真

[复制链接]
ID:339405 发表于 2018-12-16 00:52 | 显示全部楼层 |阅读模式
单片机+TLC5615 仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)

仿真图

仿真图

下载包截图

下载包截图


源码:
  1. #include <reg52.h>

  2. //接口定义
  3. sbit DA = P1^1;
  4. sbit CK = P1^2;
  5. sbit CS = P1^4;

  6. //10bit取样,1024点正弦查表数据
  7. unsigned int code sine_dot[1024]=
  8. {
  9. 0x200,0x203,0x206,0x209,0x20c,0x20f,0x212,0x215,0x219,0x21c,0x21f,0x222,0x225,0x228,0x22b,0x22f,0x232,
  10. 0x235,0x238,0x23b,0x23e,0x241,0x244,0x247,0x24b,0x24e,0x251,0x254,0x257,0x25a,0x25d,0x260,0x263,0x266,0x269,0x26d,0x270,
  11. 0x273,0x276,0x279,0x27c,0x27f,0x282,0x285,0x288,0x28b,0x28e,0x291,0x294,0x297,0x29a,0x29d,0x2a0,0x2a3,0x2a6,0x2a9,0x2ac,
  12. 0x2af,0x2b2,0x2b5,0x2b8,0x2bb,0x2be,0x2c0,0x2c3,0x2c6,0x2c9,0x2cc,0x2cf,0x2d2,0x2d5,0x2d7,0x2da,0x2dd,0x2e0,0x2e3,0x2e6,
  13. 0x2e8,0x2eb,0x2ee,0x2f1,0x2f4,0x2f6,0x2f9,0x2fc,0x2fe,0x301,0x304,0x307,0x309,0x30c,0x30f,0x311,0x314,0x317,0x319,0x31c,
  14. 0x31e,0x321,0x324,0x326,0x329,0x32b,0x32e,0x330,0x333,0x335,0x338,0x33a,0x33d,0x33f,0x342,0x344,0x347,0x349,0x34b,0x34e,
  15. 0x350,0x353,0x355,0x357,0x35a,0x35c,0x35e,0x360,0x363,0x365,0x367,0x369,0x36c,0x36e,0x370,0x372,0x374,0x376,0x379,0x37b,
  16. 0x37d,0x37f,0x381,0x383,0x385,0x387,0x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x3e3,0x3e2,0x3e1,0x3e0,
  25. 0x3de,0x3dd,0x3dc,0x3db,0x3da,0x3d9,0x3d8,0x3d6,0x3d5,0x3d4,0x3d3,0x3d1,0x3d0,0x3cf,0x3cd,0x3cc,0x3ca,0x3c9,0x3c8,0x3c6,
  26. 0x3c5,0x3c3,0x3c2,0x3c0,0x3bf,0x3bd,0x3bc,0x3ba,0x3b9,0x3b7,0x3b5,0x3b4,0x3b2,0x3b0,0x3af,0x3ad,0x3ab,0x3aa,0x3a8,0x3a6,
  27. 0x3a4,0x3a2,0x3a1,0x39f,0x39d,0x39b,0x399,0x397,0x395,0x393,0x392,0x390,0x38e,0x38c,0x38a,0x388,0x386,0x384,0x382,0x37f,
  28. 0x37d,0x37b,0x379,0x377,0x375,0x373,0x371,0x36e,0x36c,0x36a,0x368,0x366,0x363,0x361,0x35f,0x35c,0x35a,0x358,0x355,0x353,
  29. 0x351,0x34e,0x34c,0x34a,0x347,0x345,0x342,0x340,0x33d,0x33b,0x339,0x336,0x334,0x331,0x32e,0x32c,0x329,0x327,0x324,0x322,
  30. 0x31f,0x31d,0x31a,0x317,0x315,0x312,0x30f,0x30d,0x30a,0x307,0x305,0x302,0x2ff,0x2fc,0x2fa,0x2f7,0x2f4,0x2f1,0x2ef,0x2ec,
  31. 0x2e9,0x2e6,0x2e4,0x2e1,0x2de,0x2db,0x2d8,0x2d5,0x2d2,0x2d0,0x2cd,0x2ca,0x2c7,0x2c4,0x2c1,0x2be,0x2bb,0x2b8,0x2b6,0x2b3,
  32. 0x2b0,0x2ad,0x2aa,0x2a7,0x2a4,0x2a1,0x29e,0x29b,0x298,0x295,0x292,0x28f,0x28c,0x289,0x286,0x283,0x280,0x27d,0x27a,0x277,
  33. 0x273,0x270,0x26d,0x26a,0x267,0x264,0x261,0x25e,0x25b,0x258,0x255,0x252,0x24e,0x24b,0x248,0x245,0x242,0x23f,0x23c,0x239,
  34. 0x236,0x232,0x22f,0x22c,0x229,0x226,0x223,0x220,0x21d,0x219,0x216,0x213,0x210,0x20d,0x20a,0x207,0x203,0x200,0x1fd,0x1fa,
  35. 0x1f7,0x1f4,0x1f1,0x1ed,0x1ea,0x1e7,0x1e4,0x1e1,0x1de,0x1db,0x1d8,0x1d4,0x1d1,0x1ce,0x1cb,0x1c8,0x1c5,0x1c2,0x1bf,0x1bb,
  36. 0x1b8,0x1b5,0x1b2,0x1af,0x1ac,0x1a9,0x1a6,0x1a3,0x1a0,0x19c,0x199,0x196,0x193,0x190,0x18d,0x18a,0x187,0x184,0x181,0x17e,
  37. 0x17b,0x178,0x175,0x172,0x16f,0x16c,0x169,0x166,0x163,0x160,0x15d,0x15a,0x157,0x154,0x151,0x14e,0x14b,0x148,0x145,0x142,
  38. 0x13f,0x13c,0x13a,0x137,0x134,0x131,0x12e,0x12b,0x128,0x125,0x123,0x120,0x11d,0x11a,0x117,0x115,0x112,0x10f,0x10c,0x109,
  39. 0x107,0x104,0x101,0xff,0xfc,0xf9,0xf6,0xf4,0xf1,0xee,0xec,0xe9,0xe6,0xe4,0xe1,0xdf,0xdc,0xd9,0xd7,0xd4,0xd2,0xcf,0xcd,
  40. 0xca,0xc8,0xc5,0xc3,0xc0,0xbe,0xbb,0xb9,0xb7,0xb4,0xb2,0xaf,0xad,0xab,0xa8,0xa6,0xa4,0xa1,0x9f,0x9d,0x9b,0x98,0x96,0x94,
  41. 0x92,0x90,0x8d,0x8b,0x89,0x87,0x85,0x83,0x81,0x7f,0x7c,0x7a,0x78,0x76,0x74,0x72,0x70,0x6e,0x6d,0x6b,0x69,0x67,0x65,0x63,
  42. 0x61,0x5f,0x5e,0x5c,0x5a,0x58,0x56,0x55,0x53,0x51,0x50,0x4e,0x4c,0x4b,0x49,0x47,0x46,0x44,0x43,0x41,0x3f,0x3e,0x3c,0x3b,
  43. 0x3a,0x38,0x37,0x35,0x34,0x32,0x31,0x30,0x2e,0x2d,0x2c,0x2b,0x29,0x28,0x27,0x26,0x25,0x23,0x22,0x21,0x20,0x1f,0x1e,0x1d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0x107,0x10a,0x10d,0x110,
  53. 0x112,0x115,0x118,0x11b,0x11e,0x120,0x123,0x126,0x129,0x12c,0x12f,0x131,0x134,0x137,0x13a,0x13d,0x140,0x143,0x146,0x149,
  54. 0x14c,0x14f,0x152,0x155,0x157,0x15a,0x15d,0x160,0x163,0x166,0x169,0x16c,0x16f,0x172,0x175,0x178,0x17b,0x17f,0x182,0x185,
  55. 0x188,0x18b,0x18e,0x191,0x194,0x197,0x19a,0x19d,0x1a0,0x1a3,0x1a6,0x1a9,0x1ad,0x1b0,0x1b3,0x1b6,0x1b9,0x1bc,0x1bf,0x1c2,
  56. 0x1c5,0x1c9,0x1cc,0x1cf,0x1d2,0x1d5,0x1d8,0x1db,0x1de,0x1e2,0x1e5,0x1e8,0x1eb,0x1ee,0x1f1,0x1f4,0x1f8,0x1fb
  57. };


  58. //数据写入
  59. void da5615(unsigned int da)
  60. {
  61.   unsigned char i;
  62.   da <<= 6;//10有效数据左对齐
  63.   CS = 0;
  64.   CK = 0;
  65.   for (i=0;i<12;i++)
  66.   {
  67.     DA = (bit)(da & 0x8000);
  68.     CK = 1;
  69.     da <<= 1;
  70.     CK = 0;
  71.   }
  72.   CS = 1;
  73.   CK = 0;
  74. }

  75. main()
  76. {
  77.         unsigned int j;
  78.         while(1)
  79.         {
  80.                  da5615(sine_dot[j]);
  81.                 if(++j > 1023) j=0;                 
  82.         }
  83. }
复制代码

全部资料51hei下载地址:
10BitDA正弦信号发生器.zip (85.32 KB, 下载次数: 63)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:24486 发表于 2020-3-20 13:45 | 显示全部楼层
谢谢分享。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表