This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 0 : pi/64 : 2*pi; | |
y = 0.5*(sin(x)+1); | |
plot(y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SINE_LUT_SIZE (127) | |
const float sine_lut[SINE_LUT_SIZE] = | |
{ | |
0.500, 0.524, 0.549, 0.573, 0.597, 0.621, 0.645 ,0.664 ,0.694 ,0.718 ,0.730 ,0.755 ,0.779 ,0.795 ,0.810, | |
0.835, 0.853, 0.870 ,0.881 ,0.900, 0.915, 0.928, 0.940, 0.951, 0.961, 0.970, 0.978, 0.985, 0.990, 0.994, | |
0.997, 0.999, 1.000, 0.999, 0.997, 0.994, 0.990, 0.985, 0.978, 0.970, 0.961, 0.951, 0.940, 0.928, 0.915, | |
0.901, 0.886, 0.870, 0.853, 0.835, 0.817, 0.797, 0.777, 0.757, 0.735, 0.713, 0.691, 0.668, 0.645, 0.621, | |
0.597, 0.573, 0.549, 0.524, 0.500, 0.475, 0.450, 0.426, 0.402, 0.378, 0.354, 0.331, 0.308, 0.286, 0.264, | |
0.242, 0.222, 0.202, 0.182, 0.164, 0.146, 0.129, 0.113, 0.098, 0.084, 0.071, 0.059, 0.048, 0.038, 0.029, | |
0.021, 0.014, 0.009, 0.005, 0.002, 0.000, 0.000, 0.000, 0.002, 0.005, 0.009, 0.014, 0.021, 0.029, 0.038, | |
0.048, 0.059, 0.071, 0.084, 0.098, 0.113, 0.129, 0.146, 0.164, 0.182, 0.202, 0.222, 0.242, 0.264, 0.286, | |
0.308, 0.331, 0.354, 0.378, 0.402, 0.426, 0.450 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define AMPLITUDE (4000.0) | |
#define SINE_SCALE(x) (AMPLITUDE*(x)) | |
uint32_t index0 = 0; | |
DAC_WRITE_DATA(DAC, 0, SINE_SCALE(sine_lut[index0])); |
沒有留言:
張貼留言