Dear Experts,
Hi
I use the ADC channel of an ATXMEGA32A4U chip to capture audio data and send it via USB port to Computer,
The problem is that I see a periodic noise on it that I could not find what is the source of .
I disconnect the analog circuit from ADC pin and find that noise still exists,
Could you please tell me what is the source of this noise and how I can remove it.
Please listen to attached wave file.
But about the Xmega program:
1. Micro clock is set to 32MHz.
2. ADC is set to : Signed, 12 bit, right hand side, 200000 clk, Manual triggered, ADC_PIN1
3. a timer is set with frequncy of 8000 sps and in every interrupt a manual ADC capture is triggered and samples are put into a circular Queue,
Then by USB port, those data are sent to PC program.
ADC Init code:
#define MY_ADC ADCA #define MY_ADC_CH ADC_CH0 static void adc_init(void) { struct adc_config adc_conf; struct adc_channel_config adcch_conf; memset(&adc_conf, 0, sizeof(struct adc_config)); memset(&adcch_conf, 0, sizeof(struct adc_channel_config)); adc_set_conversion_parameters(&adc_conf, ADC_SIGN_ON, ADC_RES_12,ADC_REF_VCC); adc_set_conversion_trigger(&adc_conf, ADC_TRIG_MANUAL, 1, 0); adc_set_clock_rate(&adc_conf, 200000UL); adc_write_configuration(&MY_ADC, &adc_conf); adcch_set_input(&adcch_conf, ADCCH_POS_PIN0, ADCCH_NEG_NONE, 1); adcch_write_configuration(&MY_ADC, MY_ADC_CH, &adcch_conf); }
Interrupt routine to capture audio:
static void tc_callback(void) { int16_t result; adc_start_conversion(&MY_ADC, MY_ADC_CH); adc_wait_for_interrupt_flag(&MY_ADC, MY_ADC_CH); result = adc_get_result(&MY_ADC, MY_ADC_CH); if(result < 0) { result = 0; } result -= 0x0510; result *= 16; SendQ0[wsendidx]= result; wsendidx++; if( wsendidx >= QSIZE ) { wsendidx = 0; } tc_clear_overflow(&TCC0); }
Thanks for you kind help,
Mehrdad,