>> %以三角波数据为例
tridata=uint16(round([0:127]./127*4095));%三角波上升沿数据
tridata2=uint16(round([127:-1:0]./127*4095));%三角波下降沿数据
dataa=[tridata tridata2];
fileID = fopen('data.txt','w');%新建一个名为'data.txt'的文件
fprintf(fileID,'%s','tridata={0x');%以十六进制格式写入文件,文件头
fprintf(fileID,'%X',dataa(1));
fprintf(fileID,'%s0',',')
for i=2:length(dataa)-1
if(~mod(i,20))
fprintf(fileID,'%s \n',' ');
end
fprintf(fileID,'%s','0x')
fprintf(fileID,'%X',dataa(i));
fprintf(fileID,'%s',',')
end
fprintf(fileID,'%s','0x')
fprintf(fileID,'%X',dataa(i));
fprintf(fileID,'%s','};') %文件尾
fclose(fileID);
const uint16_t tridata[256]=
{0x0,0x20,0x40,0x61,0x81,0xA1,0xC1,0xE2,0x102,0x122,0x142,0x163,0x183,0x1A3,0x1C3,0x1E4,0x204,0x224,0x244,
0x265,0x285,0x2A5,0x2C5,0x2E6,0x306,0x326,0x346,0x367,0x387,0x3A7,0x3C7,0x3E8,0x408,0x428,0x448,0x469,0x489,0x4A
9,0x4C9,
0x4EA,0x50A,0x52A,0x54A,0x56A,0x58B,0x5AB,0x5CB,0x5EB,0x60C,0x62C,0x64C,0x66C,0x68D,0x6AD,0x6CD,0x6ED,0x70E,0x72
E,0x74E,
0x76E,0x78F,0x7AF,0x7CF,0x7EF,0x810,0x830,0x850,0x870,0x891,0x8B1,0x8D1,0x8F1,0x912,0x932,0x952,0x972,0x993,0x9B
3,0x9D3,
0x9F3,0xA14,0xA34,0xA54,0xA74,0xA95,0xAB5,0xAD5,0xAF5,0xB15,0xB36,0xB56,0xB76,0xB96,0xBB7,0xBD7,0xBF7,0xC17,0xC3
8,0xC58,
0xC78,0xC98,0xCB9,0xCD9,0xCF9,0xD19,0xD3A,0xD5A,0xD7A,0xD9A,0xDBB,0xDDB,0xDFB,0xE1B,0xE3C,0xE5C,0xE7C,0xE9C,0xEB
D,0xEDD,
0xEFD,0xF1D,0xF3E,0xF5E,0xF7E,0xF9E,0xFBF,0xFDF,0xFFF,0xFFF,0xFDF,0xFBF,0xF9E,0xF7E,0xF5E,0xF3E,0xF1D,0xEFD,0xED
D,0xEBD,
0xE9C,0xE7C,0xE5C,0xE3C,0xE1B,0xDFB,0xDDB,0xDBB,0xD9A,0xD7A,0xD5A,0xD3A,0xD19,0xCF9,0xCD9,0xCB9,0xC98,0xC78,0xC5
8,0xC38,
0xC17,0xBF7,0xBD7,0xBB7,0xB96,0xB76,0xB56,0xB36,0xB15,0xAF5,0xAD5,0xAB5,0xA95,0xA74,0xA54,0xA34,0xA14,0x9F3,0x9D
3,0x9B3,
0x993,0x972,0x952,0x932,0x912,0x8F1,0x8D1,0x8B1,0x891,0x870,0x850,0x830,0x810,0x7EF,0x7CF,0x7AF,0x78F,0x76E,0x74
E,0x72E,
0x70E,0x6ED,0x6CD,0x6AD,0x68D,0x66C,0x64C,0x62C,0x60C,0x5EB,0x5CB,0x5AB,0x58B,0x56A,0x54A,0x52A,0x50A,0x4EA,0x4C
9,0x4A9,
0x489,0x469,0x448,0x428,0x408,0x3E8,0x3C7,0x3A7,0x387,0x367,0x346,0x326,0x306,0x2E6,0x2C5,0x2A5,0x285,0x265,0x24
4,0x224,
0x204,0x1E4,0x1C3,0x1A3,0x183,0x163,0x142,0x122,0x102,0xE2,0xC1,0xA1,0x81,0x61,0x40,0x20,0x20};
%%matlab 生成正玄波
for b=1:256
a(b)=round(2047*sin(2*pi*(b-1)/256))+2048;
end
figure(1)
stem(1:256,a(1:256));
fid=fopen('sin_data.txt','W');
fprintf(fid,'%d,',a);
fclose(fid);
const uint16_t sin_data[256]=
{2048,2098,2148,2199,2249,2299,2349,2398,2448,2497,2546,2594,2643,2690,2738,2785,2832,2878,2924,2969,3013,
3057,3101,3144,3186,3227,3268,3308,3347,3386,3423,3460,3496,3531,3565,3599,3631,3663,3693,3722,3751,3778,3805,
3830,3854,3877,3899,3920,3940,3959,3976,3993,4008,4022,4035,4046,4057,4066,4074,4081,4086,4090,4094,4095,4095,
4095,4094,4090,4086,4081,4074,4066,4057,4046,4035,4022,4008,3993,3976,3959,3940,3920,3899,3877,3854,3830,3805,
3778,3751,3722,3693,3663,3631,3599,3565,3531,3496,3460,3423,3386,3347,3308,3268,3227,3186,3144,3101,3057,3013,
2969,2924,2878,2832,2785,2738,2690,2643,2594,2546,2497,2448,2398,2349,2299,2249,2199,2148,2098,2048,1998,1948,
1897,1847,1797,1747,1698,1648,1599,1550,1502,1453,1406,1358,1311,1264,1218,1172,1127,1083,1039,995,952,910,869,
828,788,749,710,673,636,600,565,531,497,465,433,403,374,345,318,291,266,242,219,197,176,156,137,120,103,88,74,
61,50,39,30,22,15,10,6,2,1,0,1,2,6,10,15,22,30,39,50,61,74,88,103,120,137,156,176,197,219,242,266,291,318,345,
374,403,433,465,497,531,565,600,636,673,710,749,788,828,869,910,952,995,1039,1083,1127,1172,1218,1264,1311,
1358,1406,1453,1502,1550,1599,1648,1698,1747,1797,1847,1897,1948,1998};
for b=1:256
a(b)=round(b/256*4097);
end
figure(1)
stem(1:256,a(1:256));
fid=fopen('1jcb_data.txt','W');
fprintf(fid,'%d,',a);
fclose(fid);
const uint16_t szigzag_wave_data[256]=
{
16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,256,272,288,304,320,336,352,368,384,400,416,432,
448,464,480,496,512,528,544,560,576,592,608,624,640,656,672,688,704,720,736,752,768,784,800,816,832,
848,864,880,896,912,928,944,960,976,992,1008,1024,1040,1056,1072,1088,1104,1120,1136,1152,1168,1184,
1200,1216,1232,1248,1264,1280,1296,1312,1328,1344,1360,1376,1392,1408,1424,1440,1456,1472,1488,1504,
1520,1536,1552,1568,1584,1600,1616,1632,1648,1664,1680,1696,1712,1728,1744,1760,1776,1792,1808,1824,
1840,1856,1872,1888,1904,1920,1936,1952,1968,1984,2000,2016,2032,2049,2065,2081,2097,2113,2129,2145,
2161,2177,2193,2209,2225,2241,2257,2273,2289,2305,2321,2337,2353,2369,2385,2401,2417,2433,2449,2465,
2481,2497,2513,2529,2545,2561,2577,2593,2609,2625,2641,2657,2673,2689,2705,2721,2737,2753,2769,2785,
2801,2817,2833,2849,2865,2881,2897,2913,2929,2945,2961,2977,2993,3009,3025,3041,3057,3073,3089,3105,
3121,3137,3153,3169,3185,3201,3217,3233,3249,3265,3281,3297,3313,3329,3345,3361,3377,3393,3409,3425,
3441,3457,3473,3489,3505,3521,3537,3553,3569,3585,3601,3617,3633,3649,3665,3681,3697,3713,3729,3745,
3761,3777,3793,3809,3825,3841,3857,3873,3889,3905,3921,3937,3953,3969,3985,4001,4017,4033,4049,4065,
4081,4097
};