9 years, 10 months ago.

how to use the Ticker ?

Hello, I would like to run a function every 100 microseconds. I used: flipper.attach_us(&flip,100); or flipper.attach(&flip,0.0001);

but in the two cases I get 62 microseconds apart. Why? thank you very much

Here's my flip ():

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);
    }  
}

Edit by 0xc0170: Please use code highlight syntax. Thx

Question relating to:

Be the first to answer this question.