9 years, 10 months ago.

how to use the Ticker ?

I would like to make a feature all the 90μs. For this I used

flipper.attach_us(&flip,90);

But I get in 60μs time interval, why ?

void flip() { //Envoi les valeurs automatiquement
     
    if (fscanf(fp, "%d %d %d %d ", &dac, &val, &signe, &gain)!=EOF) {
    
        if (dac==1) {
            cs1 = 0; // Select the device by seting chip select low
        } 
        else if (dac==2) {
            cs2 = 0;
        } 
        else if (dac==3) {
            cs3 = 0;
        } 
        else { /*if (dac==4)*/
            cs4 = 0;
        }
        //lcd.printf("Val=%d     \n\n",val);
        spi.write(val); // Send 0x8f, the command to read the WHOAMI register
        cs1 = 1; // Deselect the device
        cs2 = 1;
        cs3 = 1;
        cs4 = 1;
    }
    else {
        fseek(fp, 0, SEEK_SET);
    }  
}

Question relating to:

Are you certain flip() does its job within 90us?

posted by Martin Kojtal 16 Jun 2014

When I put 90μs I read the oscilloscope an interval of 60μs. When I put 150μs that's okay, I get good a time interval of 150μs. But as soon as I put the smaller values, it no longer works! Why?

posted by LouiseC LouiseC 16 Jun 2014

how are you measuring the interval? I dont know your target, check the clocks for timer. I would calculate if it is possible to generate 90uS, using your clocking configuration (default mbed?).

posted by Martin Kojtal 17 Jun 2014

I configured my connection SPI like this:

spi.format(16,1); Setup the spi for 8 bit data, high steady state clock, spi.frequency(1000000); second edge capture, with a 1MHz clock rate

The frequency is probably insufficient? I measure the time interval with an oscilloscope

posted by LouiseC LouiseC 17 Jun 2014
Be the first to answer this question.