Author Topic: AVR8 vs Cortex-M???  (Read 35253 times)

0 Members and 1 Guest are viewing this topic.

Offline Dielectric

  • Regular Contributor
  • *
  • Posts: 127
  • Country: 00
Re: AVR8 vs Cortex-M???
« Reply #100 on: April 14, 2016, 04:23:15 pm »
... put code where the vector table would go if you were using interrupts, etc.
eh?

Sometimes you can put an instruction or two right in the vector table instead of actually incurring a call.  If all you need is a flag, then an OR opcode on a reg or a byte of RAM is all you need.  I've done it and made double-sure to document that change.
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1762
  • Country: us
Re: AVR8 vs Cortex-M???
« Reply #101 on: April 14, 2016, 04:37:12 pm »
M7F got a MMU, just map all memory into one logically contiguous chunk.

This is news to me. As far as I know, the MPU in the Cortex-M7 is the same as the one in the M4, and the ARM architecture manual explicitly states:

MPU support provides control of access rights on physical addresses. It does not perform address translation.
"That's not even wrong" -- Wolfgang Pauli
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4172
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: AVR8 vs Cortex-M???
« Reply #102 on: April 14, 2016, 06:16:18 pm »
Some vendors alias the memory. Same goes for bit-banding.
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: AVR8 vs Cortex-M???
« Reply #103 on: April 14, 2016, 07:18:07 pm »
Sometimes you can put an instruction or two right in the vector table instead of actually incurring a call.  If all you need is a flag, then an OR opcode on a reg or a byte of RAM is all you need.  I've done it and made double-sure to document that change.
Maybe that worked for earlier ARM processors (haven't tried it myself), but the Cortex-M treats the vector table as a bunch of 32-bit addresses--no opcodes. One of the benefits of the architecture is that the hardware stacks some registers automatically on an exception entry, so there's less need/opportunity to play those kinds of tricks.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4298
  • Country: us
Re: AVR8 vs Cortex-M???
« Reply #104 on: April 15, 2016, 07:46:00 am »
Quote
Quote
... put code where the vector table would go if you were using interrupts, etc.
eh?
At the beginning of the ARM address space is a "vector table" that normally holds the addresses of the handlers for exceptions and interrupts and such.  It's pretty big.  On an Atmel SAMD21 there are 16 words worth of CM0-common vectors, and 28 words worth of Atmel Peripheral interrupts.
A C program normally fills them in with pointers to "unhandled_exception" or similar.   That's 176 bytes of program space, and it's one of the reasons that ARM code looks so bloated even for trivial programs.   Now, the first two words hold the initial stack pointer and the reset_handler address, which are pretty important.  But the remaining 168 bytes are only useful if you actually implement handlers for the exceptions or interrupts that they handle, so they can be reclaimed if you're really desperate.
(On a STM32f103 you have 16 words of CM3 vectors and 60 words of ST Peripheral vectors.  304 bytes!)

There are intermediate hacks - most chips seem to allow you to relocate the vector table to RAM (handy for OSes) (This is an ARM "optional" feature.)  So you can omit the table from FLASH and "build" it in RAM - if you need only a couple of interrupts (UART and SYSTick?), the code to build a RAM table probably takes less space than leaving the whole table in flash.

 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: AVR8 vs Cortex-M???
« Reply #105 on: April 15, 2016, 08:36:18 am »
On a STM32f103 you have 16 words of CM3 vectors and 60 words of ST Peripheral vectors.  304 bytes!
out of 128kiB. It is a const array of pointers. It has exactly the same size members as the ones on mega AVR8s, that is 4 bytes per one IRQ. Cannot see a spectacular difference.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4172
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: AVR8 vs Cortex-M???
« Reply #106 on: April 15, 2016, 09:12:09 pm »
The fact that you think 304 bytes is a lot means you're pushing the envelope on your current platform. Wake up, get smaller silicon!
I toss around lookup tables all over the place on ARM since you have A LOT of flash and there is no significant speed penalty reading random from flash. (there is some penalty for cache miss)
That same STM32F103 you mentioned is available with 1 MegaByte of flash. Which will only be used when you start loading images for your LCD application.

On the last project (custom PLC-ish core) I wanted to output some human readable debugs strings when an input (one of ~400) was triggered. I copied the entire schematic netlist into ann char* array. Whopping 10KB of debug content. No worries.
« Last Edit: April 15, 2016, 09:15:48 pm by Jeroen3 »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4298
  • Country: us
Re: AVR8 vs Cortex-M???
« Reply #107 on: April 16, 2016, 12:11:25 am »
Yeah, yeah.  But if you're going to say "the ARM is so horribly code-bloating that a 16k part is the minimum you should consider", it's worth pointing out that the same tricks people use to get their code working on small 8-bit micros will work on small ARMs, too (say, 4k - still "mid-sized" by 8bit standards.) (4k is also the minimum I've seen on an ARM microcontroller, I think.)
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4172
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: AVR8 vs Cortex-M???
« Reply #108 on: April 16, 2016, 11:00:54 am »
With thumb instructions a 4k flash part is really small. Comparable to a 2k AVR parts, like ATtiny's.
If you're looking for chips in this region, the price should be the determining factor.
But remember that the price consists of the chips, the work, and the tooling. If you have to buy the tooling again for low volume, it's not going to win. Same applies if you have to educate your developers again.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27825
  • Country: nl
    • NCT Developments
Re: AVR8 vs Cortex-M???
« Reply #109 on: April 16, 2016, 11:37:10 am »
The problem I have found with ST's devices is that their peripherals are allover the place and knowledge gained on one chip is totally useless for the other. You have to consider those costs as well. Just saying their evaluation boards are cheap is like saying you should buy whatever has the most shiny parts without looking under the hood.
If you are in low volume stuff (<10000 units) then it makes more sense to choose for a broad microcontroller family with consistent peripherals so you can share a lot of code between projects without having to rely on bloated hardware abstraction layers.
« Last Edit: April 16, 2016, 11:39:08 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: AVR8 vs Cortex-M???
« Reply #110 on: April 16, 2016, 01:14:44 pm »
Quote
As a result of maker movement, MCU boards are pretty cheap these days.

I don't know if that's because of the maker movement. MCU prices have gone down significantly, and manufacturing technology has advanced also, so the cost of producing a mcu board has gone down significantly. I don't dispute that the maker movement has broadened the demand and economy of scale has helped drive down the total cost.

But I think the maker movement is more a result of low prices rather than a driver of low prices.
================================
https://dannyelectronics.wordpress.com/
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: AVR8 vs Cortex-M???
« Reply #111 on: April 16, 2016, 01:36:53 pm »
(..)4k is also the minimum I've seen on an ARM microcontroller, I think.
Frankly, why would a hobbyist wanted to buy a uC that is below 128kiB? These go like $2 a pop. I would not buy a 4kiB chip even if it were $0.01 a pop. It is simply not worth saving a buck and hitting "now please skip to assembler (or rewrite a library) because we are out of flash".
Perhaps, if it were a 10k volume. But even then I doubt I'd use a 4kiB ARM.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6570
  • Country: nl
Re: AVR8 vs Cortex-M???
« Reply #112 on: April 16, 2016, 01:39:53 pm »
What I see happening all around is that people that have limited SW/HW engineering skills but want to produce something with a lot of ADC/GPIO/I2C/SPI/LCD/TCP-IP etc. take a pi or BBB.
And considering all the topics on this forum how get things going with an Cortex chip I find that a very good and wise decision.
My advice to hobbieists at this moment: simple projects: arduino/8 bitter, more advanced projects: pi or BBB or generic pcb's like that.

But the TS is no hobbieist, he is a SW engineer following education, and then you have to prepare for what a future employer wants from a fresh employee.
Then comes the decision what kind of product:
- embedded low end stuff (standalone not internet connected) my advice: Cortex M is the way to go since for any significant amount of production they will use that kind of uC's.
- embedded high end stuff (internet connected): go learn embedded linux and seperation kernels, so microprocessors with MPU/MMU that is the future where the entire IIOT v4 (Industry Internet of Things) is going to IMO.
The last I see more and more developing currently, and the requested jobs are shifting towards this esp. in the western world.


 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4298
  • Country: us
Re: AVR8 vs Cortex-M???
« Reply #113 on: April 17, 2016, 01:03:21 am »
Quote
why would a hobbyist wanted to buy a uC that is below 128kiB? These go like $2 a pop. I would not buy a 4kiB chip even if it were $0.01 a pop.
Well, yeah.  The relevant question is more like "are the $0.50 ARM chips that vendors are targeting at the same sockets currently using $0.50 8-bit chips, actually capable of doing the same job?"  (and some of them only have 4k 4kib.)  And I'm claiming that the answer is generally "yes."

Quote
It is simply not worth saving a buck and hitting "now please skip to assembler (or rewrite a library) because we are out of flash".
how do you feel about "pay $0.10 more for the chip in the same package that has more memory"?

Now, you can also see vendor claims of the sort: "ARM is so wonderful that our 16k SAMD10 chip will easily replace your 32k ATmega328." (ok, usually not that blatant.  More like "we're not even going to sell 32k SAMD10 chips, even though we do sell 32k AVRs in similar package sizes.")
This seems rather unlikely...
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: AVR8 vs Cortex-M???
« Reply #114 on: April 18, 2016, 11:04:41 am »
"embedded high end stuff (internet connected): go learn embedded linux and seperation kernels, so "

At the application level, as well as human capital management level, it is definitely true that more encapsulation (aka dumbing down) is needed. Starting up on cortex m chips isn't difficult for a competent embedded engineer but many times people less than struggle.

Here, tools like arduino present an attractive alternative. They have dumbed down the chips so much that pretty much anyone can use it.

I'm actually surprised that no OEM has taken the approach that 8051 ipcore vendors have some: they provide turn-key solutions that comes with a single purpose ide, libraries that perform 99 PCT of the targeted applications, and reference hardware designs.

This approach would have totally isolated the designer from the hardware.

Personally, going to a full blown OS like Linux is an overkill. A much simpler OS or heavy encapsulation would work.
================================
https://dannyelectronics.wordpress.com/
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6570
  • Country: nl
Re: AVR8 vs Cortex-M???
« Reply #115 on: April 18, 2016, 12:12:06 pm »
Well the reason I said that is that no company with a right mindset will sell internet connected devices without an (online updatable) security suite.
If you look at the requirements and footprints of such security solutions a lot of microcontrollers (incl. cortex m3 imo) are out of their league.

Be aware that last year was a breakthrough year where in the US companies were pursued by the FTC because their devices lacked basic security mechanisms (see attachment) ;)
Very interestng developments :)
 

Offline Dielectric

  • Regular Contributor
  • *
  • Posts: 127
  • Country: 00
Re: AVR8 vs Cortex-M???
« Reply #116 on: April 18, 2016, 04:23:52 pm »
Sometimes you can put an instruction or two right in the vector table instead of actually incurring a call.  If all you need is a flag, then an OR opcode on a reg or a byte of RAM is all you need.  I've done it and made double-sure to document that change.
Maybe that worked for earlier ARM processors (haven't tried it myself), but the Cortex-M treats the vector table as a bunch of 32-bit addresses--no opcodes. One of the benefits of the architecture is that the hardware stacks some registers automatically on an exception entry, so there's less need/opportunity to play those kinds of tricks.

Yeah, this is on older 8-bit machines (like a PSoC M8C), I don't even know how I'd attempt it on an ARM.  Actually, I wouldn't try it on ARM because the interrupt controller is too spiffy.  If I thought I needed that kind of optimization, I'd reconsider my assumptions because I'm probably doing something wrong.   ;)
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1762
  • Country: us
Re: AVR8 vs Cortex-M???
« Reply #117 on: April 18, 2016, 05:55:59 pm »
But I think the maker movement is more a result of low prices rather than a driver of low prices.

And the maker market is so totally insignificant compared to the general market that it's lost in the noise as far as the manufacturers are concerned.
"That's not even wrong" -- Wolfgang Pauli
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27825
  • Country: nl
    • NCT Developments
Re: AVR8 vs Cortex-M???
« Reply #118 on: April 18, 2016, 07:05:15 pm »
But I think the maker movement is more a result of low prices rather than a driver of low prices.
And the maker market is so totally insignificant compared to the general market that it's lost in the noise as far as the manufacturers are concerned.
I wouldn't be so sure about that. A manufacturer needs both high volume clients and a large user base to be succesful. The first to sell in quantities the second to create chances to get into high volume designs.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf