7 years, 9 months ago.

KL43Z DAC speed too slow

Hi everyone i am new to mbed (only few days).

Currently using the KL43Z try to generate Ramp waveform from DAC oupt. The DAC is 12 bit. However, if i do 100 steps from 0 to 3.3V. it gives nice waveform but it is too slow the frequency only 537.6Hz. For the project i want to goes to 3MHz.

there are some question i would like to ask:

  • Q 1.the frequency was limit by the CPU clock frequency? but it is 48MHz.
  • Q 2.if direct write to the register, will it be faster? can i use calculation formula to see how fast it can be?
  • Q 3. rewrite the library to get more efficiency ?
  • Q 4. other suggestion ?

Thank you very much

DAC ramp waveform

#include "mbed.h"
#include "AnalogOut.h"

AnalogOut dac(PTE30);// dac=0.0f, 0=0V, 1.0f=3.3V, 0.5f= 1.65V

int main()
{
    printf("SystemCoreClock = %d Hz\n", SystemCoreClock);

    while (1) {
        //incarse the voltage steadily from 0V to 3.3V
        for (float i = 0; i<=1; i +=0.1){
            dac= i;
        }
        //deacrease the voltage steadily from 3.3V to 0V
        for (float j = 1; j>=0; j-=1){
            dac= j;
        }
    }
}
Be the first to answer this question.