Go Down

Topic: Timer Mega to Due (Read 357 times) previous topic - next topic


Jan 13, 2019, 08:55 pm Last Edit: Jan 13, 2019, 08:59 pm by shuttingdown
Hello ,

I have change my Arduino Mega to Due ( because i have change my tft screen to 7inch and screen work with 3,3V only )

In my sketch i have timer for PWM

How can convert my sketch for work on Due ?

Lines : 2462 and 2576

All sketch in attachements .

( Other problem , i have home screen but no menu , just title )



Jan 14, 2019, 09:44 am Last Edit: Jan 14, 2019, 09:45 am by ard_newbie
Serch "Timer Counter arduino DUE" and you will find numerous example sketches in this sub forum.


Hi there @shuttingdown,

Have a look to the tc_lib library for the DUE available at:

- https://github.com/antodom/tc_lib

And specifically to the example action_test.ino which comes with the library. This library provides you action objects using the TC (Timer Counter) modules available in DUE's ATSAM3X8E. I think it will not be difficult to modify your code using tc_lib in order to use ATSAM3X8E's timers.

I hope it helps.



Thanks you very much for reply

I dont't be sur toi understand but i thinks :

Code: [Select]

  // TCCR3A = B00100011;        // Fast PWM on timer 3
   REG_PWM_CPRDUPD1 = B00100011;
  // TCCR3B = B11001;           //no prescalering
   REG_PWM_CPRDUPD2 = B11001;
  // OCR3A = 639;              //count to 639 (16MHz/(640-1)=25 kHz)

   //   OCR3B = Fan1PWMval;            //set PWM value for fan1
        REG_PWM_CPRDUPD3 = Fan1PWMval;
   //   OCR3C = Fan2PWMval;            //set PWM value for fan2
        REG_PWM_CPRDUPD4 = Fan2PWMval;            //set PWM value for fan2

It's ok ?

( OCR3A not modify , i don't find equality in tc_lib )



Hi there again @shuttingdown,

If what you need is to generate a PWM signal have a look to pwm_lib:

- https://github.com/antodom/pwm_lib

This library allows you to generate PWM signals using DUE's ATSAM3X8E hardware. Have a look to the examples available in the library.

If what you what is to use the hardware timers available in DUE's ATSAM3X8E have a look to tc_lib, as I mentioned in my previous message.

I am afraid to say that the Mega has an AVR architecture and the ATSAM3X8E is an ARM Cortex M3 which is a very different architecture, different device registers, other devices, etc. Have a look to ATSAM3X8E's datasheet if you want to know more.

I hope it helps.

Go Up