Teensy 3.2 DAC speedup

Status
Not open for further replies.

pmartin

Member
Hi guys,
i'm working with Teensy 3.2
I have used ADC Library for data collecting with DMA ring buffer.
I'm evaluating DAC qualitative speed on pin A14.
I get a sin wave (generated externally with a wf generator) on pin A9 (ADC_0).
then i FFT and IFFT it and put the output on A14.

Code:
void dmaBuffer_isr() {
// dmaBufffer is 256 elements long. 
    volatile int16_t* buffer = dmaBuffer->buffer();
    for(int i = 0; i < buffer_size; i++){
      samples[i + buffer_size*DMA_buffer_count] = (float)buffer[i];
    }
    DMA_buffer_count++;
    if(DMA_buffer_count == 8){ // when I reach 2048 = 256 * 8 samples, i make elaboration in processInputData()
      DMA_buffer_count = 0;
      processInputData(samples);
    }
    dmaBuffer->dmaChannel->clearInterrupt();    // clear interrupts
}

void processInputData(float *inputData) {
    minF = getFloatMin(inputData);
    maxF = getFloatMax(inputData);
    if(txMode == FALSE) {         // sono in ricezione     
        arm_cfft_radix4_instance_f32 fft_inst;
        arm_cfft_radix4_init_f32(&fft_inst, FFT_SIZE, 0, 1);
        arm_cfft_radix4_f32(&fft_inst, inputData);
        // IFFT
        arm_cfft_radix4_init_f32(&fft_inst, FFT_SIZE, 1, 1);
        arm_cfft_radix4_f32(&fft_inst, samples);
        for(int i = 0; i < SAMPLES; i++){
          uint16_t val = (uint16_t)(4095.0*(inputData[i]-minF)/(maxF - minF));
          analogWrite(A14,val);
          //Serial.println(val);
        }
    }
}

My issue is that reading A14 with a scope the wf is very scattered for frequencies > 100Hz .
I think I should use another method to output the wf on A14.

Any idea?

Thanks in advance
 
Status
Not open for further replies.
Back
Top