Author Topic: Architecture difference between Cortex-M microcontrollers  (Read 2526 times)

0 Members and 2 Guests are viewing this topic.

Offline MildInductorTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: au
Architecture difference between Cortex-M microcontrollers
« on: September 17, 2024, 09:57:58 pm »
Hello, I am comparing the STM32 (found in the STM32F411 "BlackPill") to the ATSAMD21G18 Cortex-M0+ (found in the Adafruit ItsyBitsy M0 Express). From what I can find, the STM32 seems to be based on the Cortex-M4. Because both of these boards run on the Cortex-M series architectures, does that mean the programming will be similar? I am moving away from the AVR series to something with more grunt and am trying to wrap my head around the Cortex-M series.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 12493
  • Country: us
    • Personal site
Re: Architecture difference between Cortex-M microcontrollers
« Reply #1 on: September 17, 2024, 11:58:08 pm »
Architecture only defines the core behavior. All the peripherals are different between those devices. Even the difference between CM4 and CM0+ is significant.

But if you are moving from AVR, even SAM D21 with CM0+ will be way more performant.

It is not really a 100% comparison, but you can think of it this way. Both Attiny10 and Atmega128 use AVR core, does it mean that programming them would be similar? Again, not a perfect analogy, since both devices are from the same vendor, so somewhat similar, yet they have significant differences and limitations.
« Last Edit: September 18, 2024, 12:00:34 am by ataradov »
Alex
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 3048
  • Country: au
Re: Architecture difference between Cortex-M microcontrollers
« Reply #2 on: September 18, 2024, 12:03:41 am »
Presumably you will be programming in C/C++ so the architecture will be somewhat abstracted. The M0 have a lower clock frequency than the M4, I think the M4 has a deeper instruction pipeline for the higher frequency. Mostly you will be concerned with peripherals, highest throughput and onboard RAM and FLASH, you tend to treat each device as unique mainly because of the peripherals and the application framework for each device though there is a lot of commonality. I tried the STM32 processors for quite a while but gave up because of the buggy examples code and moved across to NXP, which while not perfect I found more reliable.

P.S. The programming framework will help by providing basic code for the peripherals if selected and initialising clocks and pins and even such things as USB.
« Last Edit: September 18, 2024, 12:25:15 am by moffy »
 

Offline ArdWar

  • Frequent Contributor
  • **
  • Posts: 747
  • Country: sc
Re: Architecture difference between Cortex-M microcontrollers
« Reply #3 on: September 18, 2024, 12:43:15 am »
You likely will get more problem adjusting with the difference in peripheral setup than the difference in core architecture.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 6111
  • Country: nl
Re: Architecture difference between Cortex-M microcontrollers
« Reply #4 on: September 18, 2024, 06:38:05 am »
To know about the differences between the two MCU's it is best to read the datasheets. The same applies to the differences between the two cores.

When one plans to use assembler there are differences between the two. See https://developer.arm.com/documentation/dui0662/b/The-Cortex-M0--Instruction-Set/Instruction-set-summary?lang=en and https://developer.arm.com/documentation/ddi0439/b/CHDDIGAC for more information on this.

When using C/C++ one has to tell the compiler which core is being targeted. For instance for the gcc compiler and the Cortex-M4:

Code: [Select]
-mcpu=cortex-m4 -mthumb
The choice between the two depends also on what one wants to do. What kind of interfaces are needed and how many, like SPI, UART, CAN, ADC, DAC, etc. Also how fast does it need to be. The STM32F411 can clock up to 100MHz, where the ATSAMD21G18 can only go up to 48MHz. This also has a bearing on the max speed of the peripherals.

Both I assume have enough support in the Arduino environment, but for me to unleash the real potential of either would mean bare metal programming. That also makes moving to another manufacturer, like moffy did, unnecessary. This would only be needed when there is a hardware bug in the MCU that causes run time problems.

In the beginning bare metal programming won't allow fast development of projects, like with Arduino, but in the end, at least for me, it is way more satisfying and on my good days just as fast as developing with the use of SDK's or the Arduino environment.

So like others wrote it is not a simple one on one comparison that can be done.

Offline MildInductorTopic starter

  • Regular Contributor
  • *
  • Posts: 52
  • Country: au
Re: Architecture difference between Cortex-M microcontrollers
« Reply #5 on: September 19, 2024, 02:13:41 pm »
Thank you everyone. That clears things up :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->