Compare commits

..

2 Commits

Author SHA1 Message Date
Sanyog Nevase Nevase 34abbfbbf4 Declare waveform shape 2024-10-29 20:39:15 +05:30
Sanyog Nevase Nevase 1d8c5b2a38 DEFINE ANALOG WAVEFORM TO GENERATE 2024-10-29 20:34:37 +05:30
1 changed files with 29 additions and 3 deletions

30
main.c
View File

@ -69,14 +69,40 @@ void AOUT(uint16_t ANALOG_SAMPLE)
I2C0_SEND(MCP4725_ADDRESS, ANALOG_SAMPLE_MSB, ANALOG_SAMPLE_LSB); // SEND 12 BIT DATA I2C0_SEND(MCP4725_ADDRESS, ANALOG_SAMPLE_MSB, ANALOG_SAMPLE_LSB); // SEND 12 BIT DATA
} }
int samples[100] = { // DECLARE WAVEFORM SHAPE
2252, 2436, 2594, 2722, 2819, 2886, 2925, 2942, 2942, 2933,
2922, 2916, 2921, 2940, 2977, 3031, 3101, 3185, 3276, 3371,
3463, 3547, 3619, 3675, 3714, 3735, 3739, 3729, 3709, 3682,
3652, 3622, 3594, 3570, 3547, 3525, 3499, 3466, 3420, 3356,
3271, 3161, 3025, 2863, 2678, 2473, 2255, 2031, 1808, 1596,
1401, 1229, 1085, 973, 891, 839, 812, 804, 809, 820,
829, 831, 819, 791, 746, 683, 606, 518, 424, 330,
241, 162, 98, 51, 21, 9, 12, 27, 51, 80,
111, 140, 166, 189, 211, 235, 264, 303, 357, 431,
528, 651, 800, 974, 1170, 1382, 1604, 1829, 2047, 2252 };
void WAVEFORM(void) // DEFINE ANALOG WAVEFORM TO GENERATE
{ int i; // DEFINE VARIABLE i
while (1)
{
for ( i=0; i< 100; i++) // TAKE EACH SAMPLE OUT OF 100 SAMPLES TO SEND TO PERIPHERAL
{
AOUT(samples[i]); // SEND ith SAMPLE TO PERIPHERAL
if (samples[i] > 4095) // RESET IF SAMPLE VALUE ABOVE MAXIMUM LIMIT
{ samples[i] = 0;
}
}
delay(1000); // DELAY TO CONTROL WAVEFORM FREQUENCY
}
}
int main(void) int main(void)
{ {
systick_setting(); // SysTick setup systick_setting(); // SYSTICK SETUP
while (1) while (1)
{ {
WAVEFORM(); // WAVEFORM
} }
} }