Hi guys! I'm using an adafruit mcp4725 DAC and what I'm trying to achieve is the possibility to output an analogic value every time a clock interrupt occurs. The problem is that it is not working. The code I'm using is this one:

// Normal (single slope) PWM operation: timers countinuously count up to PER register value and then is reset to 0 REG_TCC0_WAVE |= TCC_WAVE_WAVEGEN_NPWM; // Setup single slope PWM on TCC0 while (TCC0->SYNCBUSY.bit.WAVE); // Wait for synchronization

// Each timer counts up to a maximum or TOP value set by the PER register, // this determines the frequency of the PWM operation: REG_TCC0_PER = 1919; // Set the frequency of the PWM on TCC0 to 25kHz while(TCC0->SYNCBUSY.bit.PER); // Wait for synchronization

All global variables used in an interrupt service routine have to be declared "volatile", otherwise the compiler might optimize them away (code is never reached, so don't make any machine instructions for it).

I changed all the variables to volatile but it does not work. I found that it is possible to use a flag variable changed in the interrupt and checked in the loop in order to output the desired value. The problem is that I don't know how to increase the clock frequency of the i2c from 100kHz to 400kHz or 800kHz using an arduino m0 pro. Have you got some suggestions?