I also want help from you with this error that appears when I check:
C: \ Users \ mathe \ AppData \ Local \ Arduino15 \ packages \ arduino \ hardware \ sam \ 1.6.12 \ colors \ arduino \ syscalls_sam3.c: In the '_exit' function:
C: \ Users \ mathe \ AppData \ Local \ Arduino15 \ packages \ arduino \ hardware \ sam \ 1.6.12 \ colors \ arduino \ syscalls_sam3.c: 133: 24: warning: unused parameter 'status' [-Wunused-parameter ]
extern void _exit (int status)
^
No error appears in the code, so I do not know what it can be. Can you help me with this?
This is the full code I am using:
int in_ADC0, in_ADC1; // variables for 2 values of ADCs (ADC0, ADC1)
int POT0, POT1, POT2, POT3, POT4, out_DAC0, out_DAC1; // variables for 5 pots (ADC6, ADC7, ADC8, ADC9, ADC10)
// int LED = 3;
// int FOOTSWITCH = 7;
// int TOGGLE = 2;
int sample, accumulator, count, LFO;
int effect_1 = 2;
int effect_2 = 3;
int effect_3 = 4;
int effect_4 = 5;
// int toggle_value = 0;
// int effect = 0;
int upper_threshold, lower_threshold;
#define MAX_DELAY 20000
uint16_t sDelayBuffer0 [MAX_DELAY];
uint16_t sDelayBuffer1 [MAX_DELAY];
unsigned int DelayCounter = 0;
unsigned int Delay_Depth = MAX_DELAY;
// # define MAX_DELAY 500
// # define MIN_DELAY 200
unsigned int count_up = 1;
int p;
int switch_handler = 0;
#define MAX_DELAY_A 10000
#define MAX_DELAY_B 10000
uint16_t DelayBuffer_A [MAX_DELAY_A];
uint16_t DelayBuffer_B [MAX_DELAY_B];
unsigned int DelayCounter_A = 0;
unsigned int DelayCounter_B = 0;
unsigned int Delay_Depth_A, Delay_Depth_B;
void setup ()
{
// * turns the timer on the power management control * /
pmc_set_writeprotect (false);
pmc_enable_periph_clk (TC_ID4);
// we want wavesel 01 with RC
TC_Configure (TC1,1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2);
TC_SetRC (TC1, 1, 238); // define <> interruption rate of 44.1 KHz
TC_Start (TC1, 1);
// activates the timer interrupts on the timer
TC1 -> TC_CHANNEL [1]. TC_IER = TC_IER_CPCS;
TC1 -> TC_CHANNEL [1]. TC_IDR = ~ TC_IER_CPCS;
// * Enables interrupt on null vector interrupt handler * /
// * TC4_IRQn where 4 is the timer number * timer channels (3) + channel number
// (= (1 * 3) +1) for timer1 channel1 * /
NVIC_EnableIRQ (TC4_IRQn);
// ADC Configuration
ADC -> ADC_MR | = 0x80; // DAC in free running mode.
ADC -> ADC_CR = 2; // Initiates ADC conversion.
ADC -> ADC_CHER = 0x1CC3; // Activate ADC channels 0 and 1.
// DAC Configuration
analogWrite (DAC0, 0); // Enable DAC0
analogWrite (DAC1, 0); // Enable DAC0
// set pin2 as an input and enable the internal pull-up resistor
// pinMode (LED, OUTPUT);
// pinMode (TOGGLE, INPUT_PULLUP);
// attachInterrupt (TOGGLE, switch_handler, CHANGE);
// pinMode (FOOTSWITCH, INPUT);
}
void loop ()
{
// Read the ADCs
while ((ADC -> ADC_ISR & 0x1CC3)! = 0x1CC3); // expects the conversion of ADC 0, 1, 6, 7, 8, 9, 10 to complete.
in_ADC0 = ADC -> ADC_CDR [7] // read data from ADC0
in_ADC1 = ADC -> ADC_CDR [6] // read data from ADC1
POT0 = ADC -> ADC_CDR [10] // read data from ADC8
POT1 = ADC -> ADC_CDR [11] // read data from ADC9
POT2 = ADC -> ADC_CDR [12] // read data from ADC10
POT3 = ADC -> ADC_CDR [0]; // read data from ADC7
POT4 = ADC -> ADC_CDR [1]; // read data from ADC6
}
void TC4_Handler ()
{
// We need to get the status to clear it and allow the interrupt to fire again
TC_GetStatus (TC1, 1);
if (effect_1 == HIGH) // EFFECT 1: Symmetric distortion
{
// digitalWrite (LED, LOW);
upper_threshold = map (POT0, 0, 4095, 4095,! POT0);
lower_threshold = map (POT0, 0, 4095, 0000, POT0);
// upper_threshold0 =! upper_threshold;
// lower_threshold0 =! lower_threshold;
if (in_ADC0> = upper_threshold) in_ADC0 = upper_threshold;
else if (in_ADC0 <lower_threshold) in_ADC0 = lower_threshold;
// if (in_ADC1> = upper_threshold) in_ADC1 = upper_threshold;
// else if (in_ADC1 <lower_threshold) in_ADC1 = lower_threshold;
// adjust the volume with POT4 with constant intensity
out_DAC0 = map (in_ADC0, lower_threshold, upper_threshold, 1, POT4);
// out_DAC1 = map (in_ADC1, lower_threshold, upper_threshold, 1, POT4);
// Record the DACs
dacc_set_channel_selection (DACC_INTERFACE, 0) // selects DAC channel 0
dacc_write_conversion_data (DACC_INTERFACE, out_DAC0) // write to DAC 0
// dacc_set_channel_selection (DACC_INTERFACE, 1) // select DAC channel 1
// dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
}
if (effect_2 == HIGH) // EFFECT 2: Clean.
{
// Addvolume feature with POT4
out_DAC0 = map (in_ADC0,0,4095,1, POT4);
// out_DAC1 = map (in_ADC1,0,4095,1, POT4);
// Write the DACs
dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in DAC 0
// dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
// dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
}
if (effect_3 == HIGH) // EFFECT 3: Delay.
{
// digitalWrite (LED, LOW);
// Store current readings
// sDelayBuffer0 [DelayCounter] = in_ADC0;
sDelayBuffer1 [DelayCounter] = in_ADC1;
// Set the delay depth based on the position of pot2.
Delay_Depth = map (POT2 >> 2.0,1023,1, MAX_DELAY);
// Increse / reset delay counter.
DelayCounter ++;
if (DelayCounter> = Delay_Depth) DelayCounter = 0;
// out_DAC0 = ((sDelayBuffer0 [DelayCounter]));
out_DAC1 = ((sDelayBuffer1 [DelayCounter]));
// Add volume feature
// out_DAC0 = map (out_DAC0,0,4095,1, POT3);
out_DAC1 = map (out_DAC1,0,4095,1, POT3);
// Write the DACs
// dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
// dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in the DAC
dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 0
// Clear status allowing the interrupt to be triggered again.
TC_GetStatus (TC1, 1);
}
// void switch_handler ()
// delayMicroseconds (100000); // debouncing protection
// if (toggle_value! = digitalRead (TOGGLE)) ++ effect;
// delayMicroseconds (100000); // debouncing protection
// toggle_value = digitalRead (TOGGLE);
// if (effect == 1) effect = 0;
// Delay_Depth = 300; // resets the variable.
if (effect_4 == HIGH) // EFFECT 4: Tremolo.
{
// Store current readings in ECHO mode
DelayBuffer_A [DelayCounter_A] = (in_ADC0 + (DelayBuffer_A [DelayCounter_A])) >> 1;
DelayBuffer_B [DelayCounter_B] = (in_ADC1 + (DelayBuffer_B [DelayCounter_B])) >> 1;
// Set the delay depth based on position POT2 and POT2.
Delay_Depth_A = map (POT2 >> 3,0,512,1, MAX_DELAY_A);
Delay_Depth_B = map (POT2 >> 3,0,512,1, MAX_DELAY_B);
// Increse / reset delay counter.
DelayCounter_A ++;
DelayCounter_B ++;
if (DelayCounter_A> = Delay_Depth_A) DelayCounter_A = 0;
if (DelayCounter_B> = Delay_Depth_B) DelayCounter_B = 0;
// Calculate the output as the sum of DelayBuffer_A + DelayBuffer_B
// out_DAC0 = (DelayBuffer_A [DelayCounter_A]);
out_DAC1 = (DelayBuffer_B [DelayCounter_B]);
// Add volume feature based on pot3 position.
// out_DAC0 = map (out_DAC0,0,4095,1, POT3);
out_DAC1 = map (out_DAC1,0,4095,1, POT3);
// Write the DACs
// dacc_set_channel_selection (DACC_INTERFACE, 0); // select DAC channel 0
// dacc_write_conversion_data (DACC_INTERFACE, out_DAC0); // writes in DAC 0
dacc_set_channel_selection (DACC_INTERFACE, 1); // select DAC channel 1
dacc_write_conversion_data (DACC_INTERFACE, out_DAC1); // writes in DAC 1
}}