Author Topic: where to start? AVR/ARM/PIC .....  (Read 10356 times)

0 Members and 1 Guest are viewing this topic.

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
where to start? AVR/ARM/PIC .....
« on: August 30, 2018, 11:04:28 pm »
Hi!
I'm interested in programming microcontrollers. I used Arduino UNO for a lot of projects, but it is that time to step it up and start programming in C or something else. I have some basic knowledge in C/C++/C#.. but when it comes to microcontrollers I don't know to set pins as output or input      :scared:


 I want to enter in the real stuff of programming (run away from Arduino IDE).

Where to start?

I know there are lots of controllers that do tasks for a specific project and it depend for what I need it, but at this moment it doesn't matter because I want to learn general programming..

Witch controller to use for learning and what is best to learn for today uses?

I have a bunch of atmel (microchip) atmega lying around and also got EFM8 busy bee starter kit (but there is a small amount of examples and it is hard to get started with it for me)..

I have some knowledge of electrical circuits and I'm a student of electrical engineering so all this stuff is MUST KNOW for me and I want to "master it".

Any books/pdf/forum posts to start with all this stuff?

I think that AVR atmega is good option but maybe I'm wrong (for example ARM is maybe betrer way to start learning..idk.)

Thanks!
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: es
Re: where to start? AVR/ARM/PIC .....
« Reply #1 on: August 31, 2018, 12:24:07 am »

ARM, ARM and ARM, it's the best thing to start and follow. ST STM32, LPC/Kinetis NXP, Atmel SAM S70 or the best currently for me, the RT1020/1050 NXP.

Working with ARM, means mainly, environment of development and C/C ++ compiler totally free, high portability between manufacturers, very cheap evaluation boards, a lot of technical documentation, even some interesting books (although not many).

My suggestion to start with the best is MCUXpresso of NXP as a development environment and the RT1020 / 1050 microcontroller Cortex M7 series from NXP. Another alternative is STM32 from ST, Cortex M4 and M7 with Cubemx integrated into Eclipse as a development environment.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 3998
  • Country: nz
Re: where to start? AVR/ARM/PIC .....
« Reply #2 on: August 31, 2018, 01:39:36 am »
There's nothing wrong with the Arduino UNO as hardware. Why not stick with that for a while? You can start to wean yourself from the Arduino IDE and use command line gcc and avrdude and so forth. That's no really a big deal. You can use your existing Arduino sketch source code. You can also stick to the Arduino IDE but gradually move away from using things like digitalWrite() and use direct access to the hardware instead. If you simply don't like the editor in the Arduino IDE you can use emacs or whatever with it instead (go to preferences and check "Use external editor").

Sure, eventually you might want to investigate ARM or RISC-V or other boards, but you can do a lot with AVR anyway and certainly learn all the principles with it.
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: where to start? AVR/ARM/PIC .....
« Reply #3 on: August 31, 2018, 10:11:25 am »
.
« Last Edit: August 19, 2022, 01:57:03 pm by emece67 »
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: es
Re: where to start? AVR/ARM/PIC .....
« Reply #4 on: August 31, 2018, 10:18:43 am »
About books, just today I received from Amazon the book "Embedded Systems with ARM Cortex-M microcontrollers in Assembly Language and C", last edition of 2018, a very interesting book. Mix C and assembler, and deals with virtually all subjects, including the DMA. I found it interesting to see something of assembler with ARM micros, always to add something from C, it can improve the performance in some cases.

Attached pictures about my ARM and C books. Mazidi's books are interesting, although he always ignores the DMA in all his books. There are also some Elektor books, simple but interesting for beginners.

Also a good book is "Basic concepts of embedded systems with microcontrollers based on ARM Cortex-M: a practical approach", I bought it some time ago on Amazon. This is at least a bit about DMA with some examples of sources, it is the only one, along with that of Noviello for the STM32, which deals with the DMA in a practical and theoretical way, it seems that most authors do not know what the DMA is, or they are directly afraid of it.
 
The following users thanked this post: FlyingDutch

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #5 on: August 31, 2018, 10:25:39 am »
AVRs together with avr-gcc and avrdude are fine for a lot of projects; if you are going bigger with your projects, if you wanna run big and fast TFTs, use DSPs or implement networking, you are ending up on ARM.

Personally I'm using both - AVRs and ARMs (STM32) depending on the needs; if you stuck with the gcc compiler, you can work on both platforms in similar way.
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: where to start? AVR/ARM/PIC .....
« Reply #6 on: August 31, 2018, 02:13:32 pm »
Atmel Studio (Windows only) would be a logical next step. Do away with the Arduino (IDE and) library/code and program your existing hardware (Arduino boards etc) bare metal. Learn to read the data sheet of the Atmega chips and learn (more/better) C (not C++ *). C is mainly used in ARM so get comfortable with that.

When you are comfortable with this, then you go to ARM (where the data-sheets are order of magnitude longer). You will need to learn either to program bare metal (you need that 'read long data-sheets' skill here) and/or to learn new tools and libraries (HAL etc). At this point C would be more often used and should not be a problem. Buy simple cheap hardware at first (blue pill) to get your feet wet.

[2c]

*) I am not a fan of C and think (a subset of) C++ is almost always a better choice. But fact is most use C.
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 
The following users thanked this post: Mr. Scram

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
Re: where to start? AVR/ARM/PIC .....
« Reply #7 on: August 31, 2018, 03:43:09 pm »
Atmel Studio (Windows only) would be a logical next step. Do away with the Arduino (IDE and) library/code and program your existing hardware (Arduino boards etc) bare metal. Learn to read the data sheet of the Atmega chips and learn (more/better) C (not C++ *). C is mainly used in ARM so get comfortable with that.

When you are comfortable with this, then you go to ARM (where the data-sheets are order of magnitude longer). You will need to learn either to program bare metal (you need that 'read long data-sheets' skill here) and/or to learn new tools and libraries (HAL etc). At this point C would be more often used and should not be a problem. Buy simple cheap hardware at first (blue pill) to get your feet wet.

[2c]

*) I am not a fan of C and think (a subset of) C++ is almost always a better choice. But fact is most use C.

are this things similar for coding? If I learn AVR with atmel studio would it be easy to learn ARM? Or I need to learn again from beginning like syntax (define pins with diferent functions..comunications can be setup with simmilar code in C like uart,i2c..)  ..or it is different world?
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #8 on: August 31, 2018, 03:53:03 pm »
It depends, how you want to work. I prefer bare metal, so I work me through the datasheets and write the peripheral functions myself - as plain and powerful as possible.

If you want it the easy way, you can use libraries but be warned - a very bad example for a hardware abstraction library is the one from the STM32 ARM-chips - it's a real pain, and I don't really see what it should make easier

I already ported several functions from AVR to ARM and vice versa; it's no big thing, the general syntax is the same, but sure you have to adopt things like ports and pins; but this is maybe already needed if you want to use a function from an atmega8 on an atmega16
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: where to start? AVR/ARM/PIC .....
« Reply #9 on: August 31, 2018, 04:03:58 pm »
If you have Arduino, you already have all the tools you need to do "professional" programming:

1. Some hardware
2. An editor
3. A compiler
4. A download tool (avrdude)
5. FKA Atmel datasheets

All you need to do is not use any of the Arduino core code or libraries. Really, the only difference between Arduino and "professional" programming is that you don't get all the examples, tutorials, online help, ready made hardware etc.

Also, you can do ARM programming with Arduino tools, Due is quite cheap, but also STM32 etc.

I suppose if you want to be a "total professional" you can:

1. Design and build your own hardware, using only the vendor datasheets
2. Spend weeks installing and configuring some obscure vendor toolset
3. Buy a programming tool
4. Spend weeks writing your own library code,  using only the vendor datasheets
5. Finally get round to writing some application code.
6. Find there is no help on the web, because virtually no one else is using that chip

For extra fun, the vendor datasheets and IDE are under NDA, and you can only access them after registering with a company email, (not google etc).
Bob
"All you said is just a bunch of opinions."
 

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
Re: where to start? AVR/ARM/PIC .....
« Reply #10 on: August 31, 2018, 04:09:41 pm »
It depends, how you want to work. I prefer bare metal, so I work me through the datasheets and write the peripheral functions myself - as plain and powerful as possible.

If you want it the easy way, you can use libraries but be warned - a very bad example for a hardware abstraction library is the one from the STM32 ARM-chips - it's a real pain, and I don't really see what it should make easier

I already ported several functions from AVR to ARM and vice versa; it's no big thing, the general syntax is the same, but sure you have to adopt things like ports and pins; but this is maybe already needed if you want to use a function from an atmega8 on an atmega16

yeah i understand.. I have that problem that i worked with Arduino IDE syntax ..I dont know how work with registers and other stuf and want to learn that..but there is lot of controllers but in C they all program same way or AVR/ARM/PIC/8051 have different style of programming?

What I actually want to ask is: If I spend 6 months on programming AVR can I be able to program ARM or do I need to spend another 6 months to learn basic stuf for ARM?
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #11 on: August 31, 2018, 04:26:49 pm »
If you know how to work with one, you will certainly have a clue, how to work with the other one, BUT there is no way around working you through the datasheets, finding out how the registers are named, what they do, which register bits to set how for a particular function.

You don't have to start from the scratch, but every uC has a different feature set, a different register set aso. and you have to get familiar ever again if you use a different uC
 
The following users thanked this post: NEoX

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 3998
  • Country: nz
Re: where to start? AVR/ARM/PIC .....
« Reply #12 on: August 31, 2018, 11:55:48 pm »
What I actually want to ask is: If I spend 6 months on programming AVR can I be able to program ARM or do I need to spend another 6 months to learn basic stuf for ARM?

If you're working in C/C++ then there is no difference in the logic of your program between *any* CPU, not only AVR vs ARM, but also x86, RISC-V, MIPS etc etc.

If you move from one ARM vendor to another (e.g. STM vs Atmel vs NXP) then the differences in peripherals and how you program them are essentially no different from moving between AVR and ARM.

If you need six months to learn the first one then you probably need two weeks to learn the second one.
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1473
  • Country: au
Re: where to start? AVR/ARM/PIC .....
« Reply #13 on: September 01, 2018, 03:34:25 am »
I know there are lots of controllers that do tasks for a specific project and it depend for what I need it, but at this moment it doesn't matter because I want to learn general programming..
Witch controller to use for learning and what is best to learn for today uses?
I have a bunch of atmel (microchip) atmega lying around and also got EFM8 busy bee starter kit (but there is a small amount of examples and it is hard to get started with it for me)..
I have some knowledge of electrical circuits and I'm a student of electrical engineering so all this stuff is MUST KNOW for me and I want to "master it".

If you are studying EE, then it will be very useful to know more than one MCU, and more than one single development path.
AVR is a good start, which is what Ardunio uses, but debug support is poor on the old Ardunios.

If you can get hold of one, I understand the new ARDUINO UNO WIFI REV2  has a 'proper' debug channel. 

EFM8 is also good, especially if you need good Analog. Their EFM8LB1 has 14b ADCs
You should be able to load/change/debug the examples, as good training. Their simplicity Studio IDE is common with their EFM32 parts too.

Moving up from those 8 bit ones, the next most useful adder to a CV would be ARM, if you have Silabs & AVR debug under your belt, maybe ST parts, or NXP , or Nuvoton ?
You could jump to M4 parts, or bare-metal rasp-Pi gives very good training to a EE.
 

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
Re: where to start? AVR/ARM/PIC .....
« Reply #14 on: September 01, 2018, 09:40:49 am »
thank you guys! I need to learn how to read datasheet of MCU ..but there is not lot of tutorials on the internet..are books more helpful in that part? I found some tutorials that covers datasheet and other stuff for AVR and ARM ..my biggest problem is starting with MCU (setting up pins, interrupts, watchdog, timers...) because I dont know syntax of that for MCU in C and in datasheet instruction like "set that register bit to high for enable interrupt" dosent tell me (or helps me) how to do it in C because I dont know syntax for that
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #15 on: September 01, 2018, 09:56:38 am »
Imo the datasheets from let's say an Atmega8 is really overseeable; it has a good structure and is well ordered.

If it comes to ARM like for example an STM32F103 we are talking already about a bunch more of pages, and it's already trickier to keep track over a topic, since something like a SPI already covers maybe 50-60 pages, so it means a lot of wrapping pages, better say scrolling up and down; it's a bit annoying.

for STM32 you can get "Mastering STM32", it's quite ok, but for my taste too much focused on the HAL functions; but still: the datasheet is the best and most reliable source of information.
 

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
Re: where to start? AVR/ARM/PIC .....
« Reply #16 on: September 01, 2018, 10:12:18 am »
Better to start with it then..lot of talking will not make me learn that stuff  :-DD ..time to start hard!
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #17 on: September 01, 2018, 10:15:18 am »
Start with the classical Hello World! and Blinky for whatever uC you use; based on that you can slowly extend to code - try and error; there is nothing what speaks against that method.

It's unlikely for the beginner to write pages and pages of code, compile and upload it on the chip - and voilĂ  - everything works. It would be nice, but it's unlikely to happen
 
The following users thanked this post: NEoX

Offline iMo

  • Super Contributor
  • ***
  • Posts: 4675
  • Country: nr
  • It's important to try new things..
Re: where to start? AVR/ARM/PIC .....
« Reply #18 on: September 01, 2018, 11:07:55 am »
Today people start with ..duino like environments (with free, bundled, easy to install "uniform" development tools), where the fast lead-in (or a quick win) is easy to make.

If I were you I would definitely not start with reading the datasheets or messing with HALs..

Such ..duino environments (IDEs) suitable for beginners are:

1. arduino   (avr/arm/esp8266/esp32)
2. teensy  (avr/arm)
3. stm32duino  (arm)
4. chipkit  (pic32mx/mz)
5. sloeber (eclipse based ..duino env, ~hundreds of avr/arm/pic/esp boards supported)
.. etc.

All above environments offer almost identical ..duino "language/syntax/dev_chain/libraries" (C, C++), thus to port your code from any above MCU/board to other above MCU/board is "pretty easy", many times just a plain "copy and paste" with a minor editing a few board specific pin names..

You will not be exposed to a need to mess with any register-level programming or HALs while you can develop quite demanding apps (an rtos based inclusive).

Most important for you will be the availability of many free libraries to play with and a good and responsive community forum with kind people you may ask for a help..   :)
« Last Edit: September 01, 2018, 11:59:51 am by imo »
 

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
Re: where to start? AVR/ARM/PIC .....
« Reply #19 on: September 01, 2018, 12:17:09 pm »
the thing is..I have my summer job in one company that makes vending machines and lot of prototypes ..the machines nees to be fast and clean wirtten code in assembly or C ..they are giving me scholarship until I finish uni (now Im working with electonic in that company but I like coding too). I want to learn lot of things before i start working in that company after I finish uni. So the Arduino ( I use arduino also to work with lot of things..like esp8266, sim800l...) is not best option to spend lot of time with. I need to start learning pure MCU programming in C and all of comunications (i2c,uart,rs232,spi...)
..so I want to be prepared and say at the job "yes, I know how it works and I can do it" (yes those things makes me happy) ..better to start early than when it is late. :popcorn:
« Last Edit: September 01, 2018, 02:07:59 pm by NEoX »
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #20 on: September 01, 2018, 01:40:56 pm »
Then it's a good idea to start working on plain C with a gcc, either for ARM or AVR - aiming on writing your own functions for all the busses the platforms offer
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: where to start? AVR/ARM/PIC .....
« Reply #21 on: September 01, 2018, 02:56:13 pm »
I used to work with the Atmel ATmega128 and I liked the chip a lot.  I worked under Linux so I was using avr-gcc and some form of serial programming (I have forgotten, it's been more than 15 years).  I thought the datasheet was adequate, avr-libc was well  implemented and bare hardware projects were quite straightforward.

But it was bare hardware, nothing like DigitalWrite existed.  Nor should it.

Today, everything seems to be wrapped up in some form of HAL.  You can blow it off but some of the chips are so complex you almost have to use it.  Then there is CubeMx for the STM32F series and this helps assign pins generates some code for using the various peripherals.  Not bad but not bare hardware either.  The code isn't as grim as Arduino but there is a ton of source code in the library so a lot of details are hidden.

So many choices...

I think I would start with "Mastering STM32" and just work through the book.  It begins with install the GCC toolchain and Eclipse (the IDE) and walks the user through just about everything that can be done with the devices.  It is available as an eBook (which I have) but the FULL copy is available here:

https://leanpub.com/mastering-stm32

Note that excerpts on the web are not the full copy.

I think ARM is the way to go, now and into the future.  Every chip manufacturer has one or more devices based on ARM technology so it's going to be here for awhile.  That's a much different story than the single source devices such as PIC and ATmega.

But the book, follow the yellow brick road and things should work out pretty well.
 

Offline NEoXTopic starter

  • Contributor
  • Posts: 29
  • Country: hr
Re: where to start? AVR/ARM/PIC .....
« Reply #22 on: September 01, 2018, 03:35:18 pm »
one programmer told me to start with 8 bit MCU then go to bigger processor because I will better understand how to wirte good code and optimization because powerfull MCU can take lot of sh*t and bad written code because it has power to deal with it. So im confused little bit where to start now..something 8 bit or take something "bigger".

Also I would pay for good book no problem but only if book is good written and helpful (book that I can follow from start to finish).
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: where to start? AVR/ARM/PIC .....
« Reply #23 on: September 01, 2018, 03:59:03 pm »
It's certainly not a bad idea to start with the 8bit uC, but it's no iron rule.
When you code, you should always have an eye on the binaries, especially for uC-code, where flash memory is not unlimited

It thinks for example a good idea to avoid string functions and floats on a Atmega8; they're not needed for every price; the programming convienience known from a real computer should be avoided on uC; that sometimes requires some experimenting how a function can be written fast and compact.

If you have some uC right now at home - use that one; there's no need to buy a selection of chips just to get going; take what you have, like an Atmega8, get the toolchain, get the datasheet, maybe get some peripheral like an LCD and start writing - this is in the end the step you cannot avoid doing: start somewhere, even if it's tricky
 

Offline cstratton

  • Regular Contributor
  • *
  • Posts: 62
  • Country: us
Re: where to start? AVR/ARM/PIC .....
« Reply #24 on: September 01, 2018, 04:20:51 pm »
If you're working in C/C++ then there is no difference in the logic of your program between *any* CPU, not only AVR vs ARM, but also x86, RISC-V, MIPS etc etc.

This is actually only true in very simple cases.

A primary example of hardware differences encountered in C has to do with the processor width.

For example, an `int` on most AVR compilers is a different size than it is on most ARM compilers.

Further, even for explicitly sized types such as `int8_t` and `int32_t` behavior differs.   On the 8-bit core, using a wider type than necessary costs extra memory and operations.  While on a 32-bit core, using an 8-bit type where a larger one would work can force an extra step to mask off only the required bits.

On an 8-bit machine, a 16 bit volatile counter exported from an ISR to the main loop needs a locking mechanism to avoid having it change between the two required memory read operations; on a 32-bit machine it does not need that.

And then there are issues with unaligned memory access.

And struct packing

Or endianness, though that happens to match here.

Fortunately once these issues are understood it's possible to target either situation.

Then there are things that get more specifically hardware-involved - anything to do with interrupts or peripherals.

Also differences between true and modified Harvard architectures determine if you can perform transparent access to flash memory (ie, via true pointers) on not.  And if you can write to code memory, if you need to force cache consistency.


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf