8 years, 7 months ago.

How set up the sampling speed in the ADC of the FRDM-KL25Z?.

I´m working in a project that make of mbed a osciloscope. first I tested with the AnalogIn and AnalogOut library I made a test for a rank of 500Hz to 5khz, I know that the sampling speed the ADC is given for the Timer o the Ticker, but the maxim sampling speed that can produce the ticker is 50us, because with a timer fewer to 40us, the timer or ticker does not nothing. too i tested with the FastAnalogIn and i improve the answer of the system but, I dont know how i can change the sampling speed of system for to increase the rank of the frequency of input. as well as with 50us only can to sample until 8khz because when is greatest the information was lost.

how i can to increase the sampling speed for the microcontroler KL25Z? there are some form of to sample a signal of until 50khz with the library of mbed? I add a image of the result and a image of code in mbed.

The green wave is the input signal, with a offset of 1,7v and the yellow wave is the output signal of the DAC, that input to a low pass filter for the reconstruction of the signal

thanks to all for the help that they can give me. /media/uploads/Ichan/1k.png /media/uploads/Ichan/3k.png /media/uploads/Ichan/1k.png /media/uploads/Ichan/codigo.png

1 Answer

8 years, 7 months ago.

Hi,

In my oscilloscope project I did following.
With this I could go around 20us per sample.

void initADC(void)
{
    if (numAnalogIn > 0) {
        ach[0] = new AnalogIn(PTB0) ;
    }
    if (numAnalogIn > 1) {
        ach[1] = new AnalogIn(PTB1) ;
    }
 
    ADC0->CFG1 = ADC0->CFG1 & (
        ~(
          0x80 // LDLPC = 0 ; no low-power mode
        | 0x60 // ADIV = 1
        | 0x10 // Sample time short
        | 0x03 // input clock = BUS CLK
        )
    ) ; // clkdiv <= 1
    ADC0->CFG2 = ADC0->CFG2 
        | 0x03 ; // Logsample Time 11 = 2 extra ADCK
    ADC0->SC3 = ADC0->SC3 
        & (~(0x03)) ; // hardware avarage off
}

moto

Accepted Answer

fine, then the part of code in the line 10 is for setup the parameters of the ADC and the features of this, then is necessary a "timer" for travel the vector?, or don´t necessary, how this in your example in the part "void sampleAD(void)" where you define the timer to 30us , and in that function can go the dac that show the data of adc or the dac will go in other function

thanks for help me ,

posted by David castiblanco 15 Sep 2015

First of all, you can download whole project of my oscilloscope from
https://developer.mbed.org/users/Rhyme/code/oscilloscope/

Having said that, there are a few things I'd like to note
(1) I'm not using DAC in my project.
In my Funcgen project I'm doing DACing.
(2) Yes, I'm using timer, refer to main.cpp line 268, please.

moto

posted by Motoo Tanaka 15 Sep 2015