Arduino Due and timer counters

Hi there,

I recently switched from an Arduino Uno to an Arduino Due for my project with a screen which have backlight functionality.

I use a timer which allows me, if the user does not press the buttons for a certain time, to control the decrease in brightness of the screen. My project works very well on Arduino Uno.

On Arduino Due, I add only one more line which makes me crash the compilation. I followed the datasheets, .h files and some posts on the forum.

REG_TC0_CCR0 |= TC_CCR_CLKEN;

My code works without this line. Here are the errors I have:

In file included from C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/CMSIS/Device/ATMEL/sam3xa/include/sam3x8e.h:312:0,
                 from C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/CMSIS/Device/ATMEL/sam3xa/include/sam3xa.h:44,
                 from C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/CMSIS/Device/ATMEL/sam3.h:59,
                 from C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/CMSIS/Device/ATMEL/sam.h:198,
                 from C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/libsam/chip.h:25,
                 from C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino/Arduino.h:42,
                 from C:\Users\CA_ELEC\Desktop\Projet\Projet.ino:8:
C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/CMSIS/Device/ATMEL/sam3xa/include/instance/instance_tc0.h:77:31: error: expected ')' before '*' token
 #define REG_TC0_CCR0  (*(WoReg*)0x40080000U) /**< \brief (TC0) Channel Control Register (channel = 0) */
                               ^
C:\Users\CA_ELEC\Desktop\Projet\Projet.ino:42:1: note: in expansion of macro 'REG_TC0_CCR0'
 REG_TC0_CCR0 |= TC_CCR_CLKEN;
 ^
C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\system/CMSIS/Device/ATMEL/sam3xa/include/instance/instance_tc0.h:77:31: error: expected ')' before '*' token
 #define REG_TC0_CCR0  (*(WoReg*)0x40080000U) /**< \brief (TC0) Channel Control Register (channel = 0) */
                               ^
C:\Users\CA_ELEC\Desktop\Projet\Projet.ino:42:1: note: in expansion of macro 'REG_TC0_CCR0'
 REG_TC0_CCR0 |= TC_CCR_CLKEN;
 ^
Plusieurs bibliothèque trouvées pour "Adafruit_RGBLCDShield.h"
Utilisé : C:\Users\CA_ELEC\Documents\Arduino\libraries\Adafruit_RGB_LCD_Shield_Library
Non utilisé : C:\Users\CA_ELEC\Documents\Arduino\libraries\Adafruit-RGB-LCD-Shield-Library-master
exit status 1
Erreur de compilation pour la carte Arduino Due (Programming Port)

Did I forget something?

PS: I don’t want to use a library to do this task.

Very weird....

I would delete sam file in :
C:\Users\CA_ELEC\AppData\Local\Arduino15\packages\arduino\hardware\sam

Then select a compiler version of the DUE in board manager (try an older version before 1.6.12)

Close all IDE windows, reopen an IDE window and try compiling a super basic sketch with ONLY REG_TC0_CCR0 |= TC_CCR_CLKEN; in setup(). Do not include any library before setup().

I tried the basic sketch and it compiles !

I guess that's because i didn't put this line in my setup function.
In my Arduino Uno project I made a function I call in the setup but I forgot it for my Arduino Due.

I guess it will work fine now.

Thank you !