AnsweredAssumed Answered

Sampling audio via UART (with PEx) with KL26Z64

Question asked by Gustavo Leal on Apr 12, 2015
Latest reply on Apr 13, 2015 by Gustavo Leal

Hi. I'm using a custom board with KL26Z64 and I'm trying to make a program that measures the ADC (to which a mic is connected) and sends the value via UART (serial) with a certain sample rate (in this case, 10kHz) indefinitely.

I want to capture audio to do some processing on a PC later.

I started a project with Processor Expert and added the ADC, Term (which uses AsynchroSerial) and TimerInt components. I set the timer interrupt period to 100us.

The baud rate is set to 38400 baud.

My ADC total conversion time is set to 11.68us and I'm running 3 conversions.

My code to do this task is as follows (on the timer interrupt event):

 

void TI1_OnInterrupt(void)
{
    AD1_Measure(TRUE);
    AD1_GetValue16(&leitura);
    Term1_SendNum(leitura);
    Term1_SendStr("\r\n");
}

 

As a result, I get the ADC values on my serial monitor. However, when I import these values to, say, MATLAB for processing, I see that the audio was not sampled at the correct rate.

What would be the most efficient way to do this?

 

Thanks,

 

Gustavo.

Outcomes