1

Having most of my experience on ATmega chips, and just starting up with Arduino (to reduce hardware development time) I'm happy to see that the usual registers such as TIMSK0, PCICR, TCNT1H and others can be used from the Arduino IDE just as they appear in the Atmel datasheet.

Migrating to the Arduino Due, however, came with a shock: the registers specified in the datasheet of the Cortex-M3 are not recognized by the Arduino IDE (although I downloaded the extension necessary for being able to select the Due). I wanted to do something very simple, like configuring a timer. I found TC_CMR0 in the datasheet, but the Arduino IDE doesn't recognize it. I found an example using the Arduino Due with timers in an obscure forum, and they used REG_PWM_CMR0. I tried it in the Arduino IDE, and it was accepted by the compiler.

I searched the Arduino and other forums, and couldn't find any hint whatsoever about the naming of the registers. Why are the names of the registers different? And can I find a conclusive documentation about the register names, or am I doomed to research each and every one of the hundreds of registers individually?

  • When I read the title I thought "like all the microcontrollers, they are just there, inside the package" – frarugi87 Jan 22 '18 at 16:20
1

There are a few files in the Arduino Due core that you should have a look at. They give great insight into the SAM register set up; variant.h, variant.cpp and chip.h

After that you can dive into the libsam and the many components (include/source).

The SAM code has a very different structure and style compared to AVR.

Cheers!

| improve this answer | |
0

I found almost everything I needed to know from the CPUs datasheet here. I got the link from the Due page on the Arduino website.

For all the registers I was interested in, in my case the Parallel IO registers, it seems to be the case that the Arduino library names them the same as the datasheet, but prepended with "REG_" so PIOC_OWDR (Output Write Disable Reg for PIO port C) becomes REG_PIOC_OWDR.

In addition to finding the register names, the datasheet obviously contains a lot more useful information about how the CPU works and how to get the most out of it.

I also found the header files in the Arduino library (arduino\hardware\sam\1.6.4\system\CMSIS\Device\ATMEL\sam3xa\include\instance\instance_pioc.h for the example above) to be good places to look up what the registers are called.

| improve this answer | |
  • i used the same datasheet you linked, and I also realized that the Arduino names are usually prepended with "REG_", but that's not always the case. For example, the TC_CMR didn't become REG_TC_CMR – vsz Jul 22 '15 at 14:01
  • I'd suggest looking in the folder I mentioned then to find the include file relevant to the timers to get clues for what you are looking for. – Mick Waites Jul 22 '15 at 14:06
  • This is where a recursive grep -R of the arduino installation directory can be really handy... – Chris Stratton Dec 19 '15 at 21:11
-1

The Arduino Due files you are after are located here on a Windows PC:

 C:\Users\name\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\component
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.