/*----------------------------------------------------------------------------*/ /* A function containing an array of 256 values that define a sine wave */ /* When called, returns a magnitude for a specified index */ /* */ /* Filename: waveform-sine.c */ /* Author: Larry Aamodt */ /* Version: 2/09/22 written */ /* */ /* Compiler: Keil uVision5 */ /* Hardware: NXP FRDM-KL25Z board */ /* */ /* Function use: Call sequentially with an index value from 0 to 255 */ /* data_point = get_data_pt(index) */ /* Data range: Integers from 48 to 4048 */ /* assuming a 3.3v ADC reference voltage this is .039v to 3.26v */ /*----------------------------------------------------------------------------*/ #include int32_t get_data_pt(uint32_t index); const int32_t wavedata[256] = { // this is the waveform data 2048, 2097, 2146, 2195, 2244, 2293, 2341, 2390, 2438, 2486, 2534, 2581, 2629, 2675, 2722, 2768, 2813, 2858, 2903, 2947, 2991, 3034, 3076, 3118, 3159, 3200, 3239, 3278, 3317, 3354, 3391, 3427, 3462, 3496, 3530, 3562, 3594, 3625, 3654, 3683, 3711, 3738, 3763, 3788, 3812, 3834, 3856, 3876, 3896, 3914, 3931, 3947, 3962, 3976, 3988, 3999, 4010, 4019, 4026, 4033, 4038, 4043, 4046, 4047, 4048, 4047, 4046, 4043, 4038, 4033, 4026, 4019, 4010, 3999, 3988, 3976, 3962, 3947, 3931, 3914, 3896, 3876, 3856, 3834, 3812, 3788, 3763, 3738, 3711, 3683, 3654, 3625, 3594, 3562, 3530, 3496, 3462, 3427, 3391, 3354, 3317, 3278, 3239, 3200, 3159, 3118, 3076, 3034, 2991, 2947, 2903, 2858, 2813, 2768, 2722, 2675, 2629, 2581, 2534, 2486, 2438, 2390, 2341, 2293, 2244, 2195, 2146, 2097, 2048, 1999, 1950, 1901, 1852, 1803, 1755, 1706, 1658, 1610, 1562, 1515, 1467, 1421, 1374, 1328, 1283, 1238, 1193, 1149, 1105, 1062, 1020, 978, 937, 896, 857, 818, 779, 742, 705, 669, 634, 600, 566, 534, 502, 471, 442, 413, 385, 358, 333, 308, 284, 262, 240, 220, 200, 182, 165, 149, 134, 120, 108, 97, 86, 77, 70, 63, 58, 53, 50, 49, 48, 49, 50, 53, 58, 63, 70, 77, 86, 97, 108, 120, 134, 149, 165, 182, 200, 220, 240, 262, 284, 308, 333, 358, 385, 413, 442, 471, 502, 534, 566, 600, 634, 669, 705, 742, 779, 818, 857, 896, 937, 978, 1020, 1062, 1105, 1149, 1193, 1238, 1283, 1328, 1374, 1421, 1467, 1515, 1562, 1610, 1658, 1706, 1755, 1803, 1852, 1901, 1950, 1999 }; int32_t get_data_pt(uint32_t index) { return(wavedata[index]); }