Declare waveform shape
This commit is contained in:
parent
1d8c5b2a38
commit
34abbfbbf4
27
main.c
27
main.c
|
@ -66,19 +66,32 @@ void AOUT(uint16_t ANALOG_SAMPLE)
|
|||
uint8_t ANALOG_SAMPLE_MSB = (ANALOG_SAMPLE >> 8) & 0x0F; // TAKE UPPER 4 BITS OF 12 BIT DATA TO TRANSMIT
|
||||
uint8_t ANALOG_SAMPLE_LSB = ANALOG_SAMPLE & 0xFF; // TAKE LOWER 8 BITS OF 12 BIT DATA TO TRANSMIT
|
||||
|
||||
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;
|
||||
}
|
||||
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
|
||||
}
|
||||
|
@ -87,9 +100,9 @@ void WAVEFORM(void) // DEFINE ANALOG WAVEF
|
|||
|
||||
int main(void)
|
||||
{
|
||||
systick_setting(); // SysTick setup
|
||||
systick_setting(); // SYSTICK SETUP
|
||||
while (1)
|
||||
{
|
||||
|
||||
WAVEFORM(); // WAVEFORM
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue