Does all ARM Cortex has same registers in the same series?

For example, if I wrote a code for the SAMD21 , in the Zero, with Arduino, where I set some timers by writing things to registers, is it means that all other M0 processors can run the same code ?

What are my options, if I want to work with ARM, but to be sure that when I chose one chip, I will be able to migrate that code to others ?

Right now, 2 options, Due and Zero. The first is bad for mass production, the second barely has examples.

I wonder where should you put your bet, with the ARM+Arduino.

Thanks.

if I wrote a code for the SAMD21 , in the Zero, with Arduino, where I set some timers by writing things to registers, is it means that all other M0 processors can run the same code ?

Nope. You're screwed. The Cortex M0 defines certain standard registers that are part of the "core" of the processor, but that doesn't extend to the peripherals that are different between different vendors, or even between different groups of processors from the same vendor. (For example, the Due and Zero have significantly different peripheral registers, even though they both use Cortex M chips from Atmel.)

Oh ok got it. But usually Arduino takes response for these things, for example all timer libraries are good for all Arduino boards and chips, so why is it not the same with the ARM processors ? because I am writing directly to registers? (this is because the IDE does not have timer libraries for ARM)

The real benefit of Arduino was to write a code that works almost with all processors, what am i missing here?

How can I choose a chip knowing the code is really not scaleable ?

BenStlr:
Oh ok got it. But usually Arduino takes response for these things, for example all timer libraries are good for all Arduino boards and chips, so why is it not the same with the ARM processors ?

If you are using Arduino library functions that are defined for each of your various ARM processors, the compiler will use the library specific to your target chip. You don't have to worry about the low level difference even between different processor families.

The issue is when you use direct register access to a peripheral, the Arduino libraries are bypassed and the responsibility for correctly manipulating the peripherals for any targeted device is back to you.

How can I choose a chip knowing the code is really not scaleable ?

If you write your code using only Arduino library functions to access the peripherals and those peripherals exist and are supported by the Arduino library for each specific device, your code should be portable across Arduino devices.

×´If you write your code using only Arduino library functions to access the peripherals and those peripherals exist and are supported by the Arduino library for each specific device, your code should be portable across Arduino devices×´

The Arduino does not have any timer library for the Zero, nor PWM, so does it makes it useless ?
(I must now learn and write low code for registers for each ARM)

But usually Arduino takes response for these things, for example all timer libraries are good for all Arduino boards and chips, so why is it not the same with the ARM processors ? because I am writing directly to registers?

Yes. A good library will turn the microcontroller hardware into an "abstraction" - a more general piece of code and hardware that will perform specific functions on a wider variety of different hardware. Writing directly to registers bypasses such abstraction. Sadly, many vendor libraries do a particularly poor job of abstraction: "set the timer to mode 12" is NOT abstract, and many highly abstract libraries (like the Arduino "analogWrite()" do a poor job of supporting the capabilities of the hardware. :frowning:

(this is because the IDE does not have timer libraries for ARM)

The Arduino IDE does not have "timer libraries" for AVR, either. There are some third party timer libraries for AVR. There are also some third party libraries for ARM boards. If those (different) libraries supported the same sort of abstract functions ("call this ISR after n microseconds"), then they'd be examples of good libraries.

The real benefit of Arduino was to write a code that works almost with all processors, what am i missing here?
How can I choose a chip knowing the code is really not scaleable ?

Some of the responsibility lies with the application programmer. If you want your code to be portable across many boards, you need to avoid using functions, capabilities and libraries that are very specific to a particular board. Yes, that means using digitalWrite() even though direct port access is faster. It means using more generic timer functions, and picking libraries that have been implemented on multiple boards over libraries that were only implemented once. You can always write your own libraries (or hire someone to write them for you) that supports the particular functions on the particular boards that you are interested in. It is one of the ... responsibilities of a good software vendor to add new technology to the hardware they support, but it's not instantaneous or cheap.

The Arduino does not have any timer library for the Zero, nor PWM,

The Zero certainly has PWM via analogWrite. In fact, it apparently has it on more pins than an Uno. ("All but 2 and 7" says the datasheet.)
If you want a timer library for Zero, you'll have to at least describe which timer functions you are interested in, or which AVR timer library you'd like to be compatible with. In general the (several types of) timers on the Zero are more complicated and have more features than the AVR timers (up to 32bit counts, for example. But if you started requiring 32bit counts, you'd likely never be compatible with an AVR timer library...)