Timer interrupt sketch convert from MEGA to DUE

Hello to everybody,
i’m trying to convert a sketch running on arduino MEGA, to arduino DUE, but i’ve a problem with timer interrupt management.

the sketch is used to command a multichannel triac dimmer and i use timer interrept for sincronize and manage the zerocross signal and the firing of triac.

This is the code running on MEGA:

void setup() {
TCCR1A = 0x00;  // clear
TCCR1B = 0x00;  // clear
TIMSK1 = 0x02;  // Enable the Output Compare A
OCR1A  = 1250;  // = 128 steps on 50hz with no timer prescale


for (int x = 0; x < countTriac; x++)
 if (canaleTriac[x] = = dimLevel | | canaleTriac[x] = = dimLevel + 1) {        // fire second triac
     digitalWrite(pinTriac[x], HIGH);

if (dimLevel == MAX_LEVEL + 1) {
     digitalWrite(pinTriac[x], LOW);
   TCCR1B = 0;

void zero_cross_detect() {
TCNT1  = 0;          // reset timer - count from zero
TCCR1B = 0x09;       // start timer with no prescale and reset tcnt1 on compare

start_low_fix = false;
dimLevel = 0;

the problem is that arduino due have different functions and registers for timer, and i’m not able to find the right way to write the code

someone found the same problem, or can give me help.

Thanks to everybody that will help me.

Considering the barrage of responses, you are better off sticking with the UNO or MEGA2560. (as a plus you don't have to deal with 3.3 volt I/O !)

DUE interrupts are a whole different animal.

Here is thread where there was a bit of interrupt head banging going on. It will either help you or deter you further from using the DUE :)

[Timer Interrupts on Due]