Author Topic: Microcontrollers for beginners  (Read 7389 times)

0 Members and 1 Guest are viewing this topic.

Offline M.Zohaib UsmanTopic starter

  • Supporter
  • ****
  • Posts: 26
  • Country: ca
Microcontrollers for beginners
« on: April 14, 2021, 07:14:33 pm »
Hey everyone! I just completed my Arduino course and was planning to move onto something more professional like ATmega or PIC microcontrollers and processors. Can you guys please suggest which is the best place to start from? please let me know about different programming devices like Pickit and stuff im totally confused with them. Thanks in advance
Student Electronics Engineer. Working on Several different projects ATM. Hit me up if interested
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Microcontrollers for beginners
« Reply #1 on: April 14, 2021, 08:42:40 pm »
I'd start with Microchip. A low end device like a pic16 or pic12 series, with few peripherals to not get overwhelmed at first.
MplabX is actually pretty good, the libraries are simple, and microchip forums are a great source of information.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: M.Zohaib Usman

Offline tmadness

  • Regular Contributor
  • *
  • Posts: 83
  • Country: us
Re: Microcontrollers for beginners
« Reply #2 on: April 15, 2021, 05:34:47 am »
A few things for your continued learning:
What is the extent of your understanding of how a microcontroller works inside ? Do you know what a memory mapped register is for example? Can you program a spi/timer/i2c/uart peripheral using a datasheet and registers?
If you answered no to the above then I would suggest stick with the atmega 328/arduino that you are probably using and rewrite your learned examples from the ground up. If you want to just move onto a more powerful platform, I suggest you look into the Teensy series. All the currently supported Teensy are ARM mcus from freescale/NXP.
 
The following users thanked this post: M.Zohaib Usman

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Microcontrollers for beginners
« Reply #3 on: April 15, 2021, 05:40:33 am »
You can go a long way with Arduino, the next step is probably standard C rather than the bastardized flavor of C++ Arduino uses. The specific hardware is not particularly important, you can even use the same atmega parts the Arduino uses. What is important is learning the language, once you know C well you can easily transition to a different microcontroller family. When you want to step up from there, STM32 seems to be the future. They're complex parts with datasheets hundreds of pages long so there's a lot to learn but it's still C.
 
The following users thanked this post: AmnevaR, M.Zohaib Usman

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Microcontrollers for beginners
« Reply #4 on: April 15, 2021, 09:23:43 am »
Hi,

Completing a course is just the beginning, until you actually code your own project/s its hard to fully appreciate the full extent of the Arduino and C++.

You can switch to other micros, but their coding is still quiet similar to C++, just that things are done in slightly different ways from one manufacturer to another.

Our choice, once you have developed some Arduino projects of your own, would be to move onto the ESP32 which is Arduino IDE and C++ compatible, as is the Teensy range.
That more easily  allows you to open up the online world  to your projects, eg wifi and bluetooth.

You good link has a wealth of free ESP projects and code examples, plus paid for courses if thats your thing.

https://randomnerdtutorials.com/



 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: Microcontrollers for beginners
« Reply #5 on: April 15, 2021, 10:22:13 am »
Hey everyone! I just completed my Arduino course and was planning to move onto something more professional like ATmega or PIC microcontrollers and processors. Can you guys please suggest which is the best place to start from? please let me know about different programming devices like Pickit and stuff im totally confused with them. Thanks in advance

Hi, this is my standard reply to this often asked question.

I personally don’t recommend The Arduino System because it was designed for people like artists with little technical knowledge so they could use libraries and ‘sketches’ to easily assemble (like Leggo) projects such as led lighting controllers for ice sculptures.

No embedded engineer would ever use Arduino, or recommend it to anyone wanting to learn about microprocessors. The only people recommending Arduino are Arduino users and Arduino kit and part sellers.

If you learn Arduino, you’re learning The Arduino System, you’re not learning microprocessors, even tho Arduino kits have a microprocessor in them.

Furthermore, the MEGA8 used in Arduino is ancient 8 bit technology, it was released way back in 1997!

Would your friends recommend a Stanley Steamer for your first car because it’s simple, instead of a easy to drive but complex Tesla electric car ?

Arduino uses The C Programming Language, which is widely assumed to be the superior programming language for embedded, except it isn’t. C was not designed for small embedded use.

Assembly language was designed for embedded and it will aid you in understanding microprocessors, unlike C which will just add another massive task for you on top of learning about microprocessors.

So I recommend a virtual Intel 8085 CPU and Assembly language using the Java based simulator in the url below. That way you don’t have to spend any money on hardware until you have enough experience to make an informed choice in a world of slick profit oriented advertising.

Learning Microprocessors’ a guide for using a useful Java based software, online book, and student examples. https://learning-microprocessors.sourceforge.io/

If embedded isn’t the most exciting thing you’ve ever seen or if it’s too boring, too hard, or takes too long to learn I recommend you examine your motivation for wanting to learn about microprocessors because more than likely you’re not going to be designing embedded devices in the long run. You will most likely be just be another Arduino kit sale.

If you gleefully assimilate all the 8085 info, choose your micro and build projects asap, LOTS of them because that’s the fast track. My recommendation is to choose a micro that has a well developed, proven and Free Software development environment, including advanced debugging behind it, preferably Linux, not Windows only.

Finally, be aware that microprocessors such as the STM32H7xx are light years ahead of the 8085, Mega8 and Cortex-M0 (my favorite), so you have a LOT of catching up to do once you have mastered the basics.

Good luck and have fun!

The author also maintains:

    Bluepill Diagnostics: https://mecrisp-stellaris-folkdoc.sourceforge.io/bluepill-diagnostics-v1.6.html
    Mecrisp-Stellaris Forth for Cortex-M; The Unofficial Doc: https://mecrisp-stellaris-folkdoc.sourceforge.io/
 
The following users thanked this post: Shock, M.Zohaib Usman

Offline mon2

  • Frequent Contributor
  • **
  • Posts: 463
  • Country: ca
Re: Microcontrollers for beginners
« Reply #6 on: April 15, 2021, 10:24:46 am »
PICO PI is coming along very nicely and @ $4 - $5 USD resale is hard to beat. Now Arduino is building a variant using the PICO PI so looks very promising.

The PIO PI PIO interface is very much welcomed to mimic FPGA like state machines to communicate at blazing speed with external hardware that the current Arduino designs cannot support. Check out the many youtube videos and articles on the PICO PI and the PIO interface.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #7 on: April 15, 2021, 11:40:06 am »
So I recommend a virtual Intel 8085 CPU and Assembly language using the Java based simulator in the url below. That way you don’t have to spend any money on hardware until you have enough experience to make an informed choice in a world of slick profit oriented advertising.

This has got to be the worst advice ever!

First of all criticising the ATMega328 for being 8 bit and released way back in 1997 -- and then recommending instead to use an 8 bit 8085 released in NINETEEN SEVENTY SIX.

The AVR is better in every way, and in particular is at least 10 times more friendly to program in assembly language.

The 8085 (like the 8080/z80) is also an absolutely awful target for a high level language compiler. Whereas the AVR is a nice one.

Can you even buy a real 8085 now? I couldn't find one in a few minutes looking.

As far as I understand, the 8085 typically ran at 3 to 6 MHz, and needs 4 or 8 or maybe 12 clock cycles to execute an instruction. Basically, somewhere or under 1 MIPS. Maybe you can buy faster ones now -- after all you can get a 17 MHz 65C02 now.

The AVR executes most instructions in 1 clock cycle, so a 16 MHz AVR is basically a 16 MIPS CPU.

Maybe you meant the 8051. I don't know. It's also awful and from 1980 but it's probably better. And you can easily buy them now.

But the guy already *has* (I presume) an Arduino with an AVR.


Claiming there is somehow something "unprofessional" about learning to program an AVR microcontroller in C or assembly language just because it happens to be mounted on an Arduino is the height of arrogant and unprofessional bullshit.
 
The following users thanked this post: mathsquid, newbrain, james_s, WattsThat, harerod, srb1954

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Microcontrollers for beginners
« Reply #8 on: April 15, 2021, 12:03:54 pm »
Depends in part what the OP is using micros for, just as part of his electronics hobby or as a path to employment ?

The advantage of the Arduino is that its so user friendly and well supported and wonder why folk knock it so much as it allows so many to venture into a new world of micros;   but as said. agree it does not give much insight as to the real working of the chip.

However not everyone can jump straight into Assembly code, particularly if doing so from home on their own without direct assistance as you would have if done at work or part of a college course etc.

We started out, many years ago,  with Machine Code on National Semiconductor chips but thankfully other workfolk and Farnells tech reps around to help us get started.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12863
Re: Microcontrollers for beginners
« Reply #9 on: April 15, 2021, 12:23:38 pm »
You can program ATmega and other AVR based Arduinos in raw C++ using the GCC AVR libraries.  The Arduino IDE installer installs a reasonably current version of the AVR GCC toolchain.  Its possible to use the Arduino IDE for raw C++ programs (with some limitations on file names, and you cant attach your own ISR to the Timer 0 overflow interrupt). 

See my comments (starting at #41) in https://www.eevblog.com/forum/blog/adventures-in-avr-isp-programming/

Also Westfw's comments are worth noting. At #35 he presents a batch file:
Code: [Select]
REM install-avr-tools.bat by Bill Westfield (WestfW)
REM  Find the avr-gcc tools that are part of an Arduino install, and
REM  add them to the PATH for the duration of the current shell.
REM  See [url]https://hackaday.io/project/19935[/url]
REM  [url]https://github.com/WestfW/Arduino-avr-tools-install[/url]
which you can use to let you use the AVR GCC installed by Arduino from the command line or from an alternative IDE launched from a batch file.

https://github.com/WestfW/Arduino-avr-tools-install

N.B. MPLAB X wants a full install of Microchip 'flavored' AVR-GCC and wont let you use the one from Arduino for AVR devices even though you can add it as a toolchain.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #10 on: April 15, 2021, 01:16:24 pm »
Depends in part what the OP is using micros for, just as part of his electronics hobby or as a path to employment ?

The advantage of the Arduino is that its so user friendly and well supported and wonder why folk knock it so much as it allows so many to venture into a new world of micros;   but as said. agree it does not give much insight as to the real working of the chip.

Nothing about Arduino prevents you getting insight into the real working of the chip!

You've got an editor. You've got a C compiler and assembler. You've got the headers with the register definitions. You've got a board with an AVR chip on it.

I really don't understand why so many people seem to think buying and using an Arduino restricts you to using only the Arduino libraries. It simply doesn't.
 
The following users thanked this post: Siwastaja, Ian.M, newbrain, george.b, james_s, tmadness, WattsThat, harerod

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: Microcontrollers for beginners
« Reply #11 on: April 15, 2021, 01:21:09 pm »
Depends in part what the OP is using micros for, just as part of his electronics hobby or as a path to employment ?

The advantage of the Arduino is that its so user friendly and well supported and wonder why folk knock it so much as it allows so many to venture into a new world of micros;   but as said. agree it does not give much insight as to the real working of the chip.

However not everyone can jump straight into Assembly code, particularly if doing so from home on their own without direct assistance as you would have if done at work or part of a college course etc.

We started out, many years ago,  with Machine Code on National Semiconductor chips but thankfully other workfolk and Farnells tech reps around to help us get started.

When I started in embedded in 1976 it was a task and a half to get a bare cpu up and running, the 6800 needed special clocks etc, the 6802 with only the requirement for a single clock was a revelation. I was a technician back then and we were expected to know. There were no courses on Microprocessors because few places had them. My first micro was a National PACE 16 bit development system with a teletype and paper tape.

Nowadays of course, assembly is so easy because there are so many free tools, real and virtual that for anyone serious about 'learning microprocessors' the task is much easier than back then.

That's why I recommended a virtual 8085, nothing to spend and the software is free. The url links a great book and would provide a decent start to a person wanting to learn the basics of *microprocessors*.

I don't care that it's old, its real, everything is there and everything we now have was birthed back in those days. I don't care if it's hard, lots of things are hard, either do them, or do them not.

Any idiot can 'make' something with Arduino, but they won't know anything worthwhile about microprocessors afterwards.



 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12863
Re: Microcontrollers for beginners
« Reply #12 on: April 15, 2021, 01:36:01 pm »
Nothing about Arduino prevents you getting insight into the real working of the chip!
Yes.  You can even debug on an Arduino, by cutting the jumper that connects Reset to the coupling capacitor to the USB UART chip and connecting any AVR debugger that supports Atmel debugWIRE to the ISP header using GDB or any IDE that supports it.  If you are feeling really cheap, you can hack together a 5V only clone of the Xplained onboard mEDBG debugger using an Arduino Leonardo or Micro and a few passives.  See https://hackaday.io/project/162372-xplained-yourself

N.B. Returning the Arduino to original functionality involves reFlashing the Arduino bootloader and reconnecting the Reset jumper.
 
The following users thanked this post: tmadness

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Microcontrollers for beginners
« Reply #13 on: April 15, 2021, 02:42:39 pm »
I really don't understand why so many people seem to think buying and using an Arduino restricts you to using only the Arduino libraries. It simply doesn't.

I agree completely.  When I want to build something down and dirty, I reach for the Arduino.  It's about project completion, there are no style points awarded.

I don't like the Arduino IDE but I can use VSCode to do the same thing.  The problem with that elegant editor/IDE is that it can't print anything.  I can't even get a source listing without having to pull the file into Notepad++.  I can also use VisualStudio and the vsMicro add-in.  Yes, I'm old enough that I annotate source listings.  The only thing that has changed is that I don't have a full-width line printer and I'm stuck with Letter size and Landscape orientation.  Workable...

Think you already know Arduino?  Try this kit

https://www.amazon.com/ELEGOO-Project-Tutorial-Controller-Projects/dp/B01D8KOZF4

Now we're getting down to hardware.  The example code is excellent as are the tutorials.

Once all the peripheral hardware is understood, it doesn't make much difference which uC is used.  That new Teensy 4.1 is quite powerful and the libraries mirror much of what Arduino provides.  The source is given so writing to bare metal is easily learned.  For that matter, there is a lot to learn in the Arduino libraries and that code is given as well.

I wouldn't wish the PIC 16F series on my least favorite cousin.  Most C compilers emit horrendous code due to banking and paging issues of the hardware design.  A horrible suggestion!

As a next step, I might recommend the PSOC 6 BLE (Bluetooth Low Energy) and specifically starting with the PSOC 6 101 video series.  I can't convince myself that version 4.4 of the toolchain works with the tutorials so I recommend installing 4.2.

Once started on the ARM series, the sky is the limit.  I started with the LPC2106 and the LPC2148.  These are excellent but obsolete.  I moved to the mbed LPC1768 and I really like the 'stamp' form factor.  I use the ARM provided online tool chain.  It's really easy to drop in a TCP/IP stack and use Berkeley Sockets to connect between the LPC1768 and a LaserJet.

Any of the STM boards will be approachable through the toolchain and i have played with several variants.  The thing is, I don't really learn anything until I build something.  There simply must be an application worthy of the time required to get up to speed.

The ATmega328 of the Arduino can be programmed at the bare metal level while using the Arduino supplied tools and boot loader.  It is possible to avoid the Arduino libraries, omit the setup()/loop() structure and add a main() function.  Then you can write every line of code that runs on the chip.  Or study the avr-gcc libraries.  I wrote some robotics code for the ATmega128 and that is an elegant chip.  Lots of pins!

I have yet to see any Arduino code that uses the features of C++ and I'm pretty much convinced that C++ features are not required (and likely not desired) in embedded programming.  I object to having a heap that can grow without bound and crash into the stack without warning.  I like static allocation!  I think I'll stick with C.  Most of the Arduino code I see in the wild is actually C code.

If your Arduino board uses the DIP package, you can do all your development on the Arduino board and then insert the chip into your custom board and nobody will ever know it is based on the Arduino.
« Last Edit: April 15, 2021, 02:46:12 pm by rstofer »
 
The following users thanked this post: tmadness

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Microcontrollers for beginners
« Reply #14 on: April 15, 2021, 07:42:09 pm »
Hey everyone! I just completed my Arduino course and was planning to move onto something more professional like ATmega or PIC microcontrollers and processors. Can you guys please suggest which is the best place to start from? please let me know about different programming devices like Pickit and stuff im totally confused with them. Thanks in advance

Hi, this is my standard reply to this often asked question.

I personally don’t recommend The Arduino System because it was designed for people like artists with little technical knowledge so they could use libraries and ‘sketches’ to easily assemble (like Leggo) projects such as led lighting controllers for ice sculptures.

No embedded engineer would ever use Arduino, or recommend it to anyone wanting to learn about microprocessors. The only people recommending Arduino are Arduino users and Arduino kit and part sellers.

If you learn Arduino, you’re learning The Arduino System, you’re not learning microprocessors, even tho Arduino kits have a microprocessor in them.

Furthermore, the MEGA8 used in Arduino is ancient 8 bit technology, it was released way back in 1997!

This makes no sense at all, Arduino has not used the atmega8 in many years, the lowest you see anymore is the atmega328 but there are also numerous far more powerful chips available.

The rest is mostly nonsense too that sounds like somebody who never actually touched an Arduino and just has an idea in their imagination of what it is and who uses it. Yes it has warts, the "IDE" if you can call it that is pretty terrible, the language is not standard C++, although the C++ stuff is all there, it just has some crutches rolled into it that makes it easier for beginners. It's true that professional embedded engineers are not going to be using the Arduino environment to develop on, but a great many of them likely cut their teeth on it. Arduino is great for beginners, and I very much wish it had been around when I was a kid, it would have given me a huge head start. It lowers the initial hump in the learning curve considerably and makes it really easy to get going. A person who has become proficient with Arduino can easily transition to something more serious. Coding is coding, once you're familiar with the C/C++ syntax, and Arduino will get you there, making the jump to ANSI C on any other microcontroller is much easier than initially learning to code.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Microcontrollers for beginners
« Reply #15 on: April 15, 2021, 07:56:34 pm »
When I started in embedded in 1976 it was a task and a half to get a bare cpu up and running, the 6800 needed special clocks etc, the 6802 with only the requirement for a single clock was a revelation. I was a technician back then and we were expected to know. There were no courses on Microprocessors because few places had them. My first micro was a National PACE 16 bit development system with a teletype and paper tape.

Nowadays of course, assembly is so easy because there are so many free tools, real and virtual that for anyone serious about 'learning microprocessors' the task is much easier than back then.

That's why I recommended a virtual 8085, nothing to spend and the software is free. The url links a great book and would provide a decent start to a person wanting to learn the basics of *microprocessors*.

I don't care that it's old, its real, everything is there and everything we now have was birthed back in those days. I don't care if it's hard, lots of things are hard, either do them, or do them not.

Any idiot can 'make' something with Arduino, but they won't know anything worthwhile about microprocessors afterwards.



Ok well it's not 1976 anymore (or 1986, or 1996, or 2006, or even 2016) and the embedded world doesn't work the way it did back then. Very few embedded engineers program anything in assembly anymore, at least 95% of it is done in C. Nobody really cares about the basics of microprocessors, that's something you learn about in the process of earning a CS degree and then mostly shove into the back of your mind as something that's useful to know but not something you really have to think about on a daily basis. Anyone wanting to get into embedded development today, especially if they have any inkling of doing so professionally needs to learn C, period. Assembler can be handy in certain situations and someone who is interested in diving in a little deeper should play around with it but they'll probably go their whole career without ever actually needing it.

Now, that said, I personally find ancient microprocessors fascinating, my favorite so far is the 6502 but I also have 6800, 6809 and Z80 based systems, mostly implemented as soft microprocessors in FPGAs but I do also have a real vintage Heathkit ET-3400 trainer and have dabbled in assembly for all of these microprocessors. It's fascinating stuff, I love it, it would be great to see more younger folks interested in it, but would I recommend a beginner pick up any of those platforms and start learning assembly? Absolutely not, it's like learning to churn butter, blacksmith horseshoes by hand or draft calligraphy with a feather quill pen, once valuable these are no longer useful life skills in the world of today. They can be fascinating, absolutely, but it is not something anyone needs to learn unless they find it interesting.

 
The following users thanked this post: woofy

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Microcontrollers for beginners
« Reply #16 on: April 15, 2021, 11:12:32 pm »
Huh, arduino and C++? That's not the best start from my point of view. I admit I do hate it.

C++ is way more complicated than C. Also not many MCUs can be programmed with that.
On top of that, Arduino C++ libraries are an absolute cryptic messy stuff, I never could understand a *** when trying to figure out something.
It happens like in Linux, it's all an uncontrolled mess, you make a project, it works, after 2 months it crashes on build spitting thousands of different errors because some library updated.
Of course, in that moment  you don't have a clue of what or why it's happening, get ready for the happy following days debugging and punching the table until you finally find the culprit.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline tmadness

  • Regular Contributor
  • *
  • Posts: 83
  • Country: us
Re: Microcontrollers for beginners
« Reply #17 on: April 16, 2021, 12:46:40 am »
My man OP you have rekindled the eternal flame war.  >:D
Stand back and let it grow.
Anyway, I strongly suggest that you keep using the parts that you have and just learn at a deeper level what is going on inside your microcontroller. Most of this learning will transfer, you can use whatever tools you want (c/c++/rust/ada/assembly, ARM/MIPS/RISCV, PIC/AVR/ATSAM/IMX ARduino/STHAL/CMSIS whatever) The key aspect is that you expand your knowledge beyond #include <SPI.h> adds SPI functionality. 
Start here: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf  if you are using a Arduino uno this is the chip you are using. There are ~300 pages. You will understand little at first. Use google for every single word you dont understand. There are hundreds of quality tutorials:
https://www.arduino.cc/en/Reference/PortManipulation
https://hekilledmywire.wordpress.com/2011/02/23/direct-port-manipulation-using-the-digital-ports-tutorial-part-3/
Follow some of them. Re do your course using register manipulation.
Finally here's  a test of your research skills and knowledge: Do not use any arduino libraries and try and write your own printf. Its something nearly every beginner learns to do.
 
The following users thanked this post: M.Zohaib Usman

Offline M.Zohaib UsmanTopic starter

  • Supporter
  • ****
  • Posts: 26
  • Country: ca
Re: Microcontrollers for beginners
« Reply #18 on: April 16, 2021, 02:55:14 pm »
Im actually still a student and am trying to get into professional electronics field, not just a hobbyist
Student Electronics Engineer. Working on Several different projects ATM. Hit me up if interested
 

Offline M.Zohaib UsmanTopic starter

  • Supporter
  • ****
  • Posts: 26
  • Country: ca
Re: Microcontrollers for beginners
« Reply #19 on: April 16, 2021, 02:58:38 pm »
Depends in part what the OP is using micros for, just as part of his electronics hobby or as a path to employment ?

The advantage of the Arduino is that its so user friendly and well supported and wonder why folk knock it so much as it allows so many to venture into a new world of micros;   but as said. agree it does not give much insight as to the real working of the chip.

Nothing about Arduino prevents you getting insight into the real working of the chip!

You've got an editor. You've got a C compiler and assembler. You've got the headers with the register definitions. You've got a board with an AVR chip on it.

I really don't understand why so many people seem to think buying and using an Arduino restricts you to using only the Arduino libraries. It simply doesn't.


Exactly what i was thinking! everyone keeps on telling me that learning arduino is totally different from the actual method of using microprocessors and controllers
Student Electronics Engineer. Working on Several different projects ATM. Hit me up if interested
 

Offline M.Zohaib UsmanTopic starter

  • Supporter
  • ****
  • Posts: 26
  • Country: ca
Re: Microcontrollers for beginners
« Reply #20 on: April 16, 2021, 03:07:14 pm »
Huh, arduino and C++? That's not the best start from my point of view. I admit I do hate it.

C++ is way more complicated than C. Also not many MCUs can be programmed with that.
On top of that, Arduino C++ libraries are an absolute cryptic messy stuff, I never could understand a *** when trying to figure out something.
It happens like in Linux, it's all an uncontrolled mess, you make a project, it works, after 2 months it crashes on build spitting thousands of different errors because some library updated.
Of course, in that moment  you don't have a clue of what or why it's happening, get ready for the happy following days debugging and punching the table until you finally find the culprit.

How else should i start then? i need your opinion
Student Electronics Engineer. Working on Several different projects ATM. Hit me up if interested
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12863
Re: Microcontrollers for beginners
« Reply #21 on: April 16, 2021, 04:12:19 pm »
Quote from: M.Zohaib Usman
Exactly what i was thinking! everyone keeps on telling me that learning arduino is totally different from the actual method of using microprocessors and controllers
Not totally different just *VERY* different.  Arduino is some half-assed hardware*, a <expletively> crappy but novice friendly IDE, a build system that sucks, and a massively bloated hardware abstraction layer that tries to make every MCU Arduino have ever used look identical to the programmer.

Also there's a culture in 'Arduinoland' of (I estimate) 99% of users not reading MCU or peripheral chip datasheets.  If you want to see violations of electrical and timing specs galore, just look for an Instructable or Yotube video of how to hook up <whatever> to an Arduino!   

If you workaround the build system by *not* putting any code in the .ino file, and program whichever ATmega is on your board in pure 'vanilla'# ISO C99, AVR Libc, and  direct SFR access using the names and bit names in the datasheet, checked against the specific MCU's register definition header, you are effectively programming in 99.9% 'pure' AVR 'flavored' C, writing code that would directly port to Atmel Studio.   

* The Arduino hardware developers have had a history of making questionable design choices and mistakes.  The most widely known one is the 0.16" gap between the two digital headers on the Uno, which makes it excessively awkward to use 0.1" pitch protoboard for a shield, and has been inherited by every full sized successor Arduino. Others include the capacitively coupled Reset signal from the USB <=> serial chip to the AVR which prevents debugWIRE working while its connected and also forces a Reset every time the serial port control line driving it goes low, which makes it *VERY* difficult to open the COM port without resetting the Arduino - resulting in bodgery like adding 10uF capacitors on reset to suppress the reset pulse from the serial chip while still allowing the reset button to work, but in doing so violates the electrical specs of both the serial chip and the reset switch! - and the marginal copper area for the linear 5V regulator present on most boards, which forces the use of a low Vin to power the board to reduce dissipation if your load on the 5V rail (including loads on high output pins) is significant. There are others . . .

# The AVR-GCC C++ compiler toolchain provided with the Arduino ADE is backwards compatible with ANSI C and ISO C99. You can use 'vanilla' ANSI C, but you'd loose C99 single line // comments and the ability to declare variables at point of first use (e.g.
for(int i=0;  i<LIMIT; i++){ /*...*/ } ) rather than only immediately after the { at the beginning of a block.
« Last Edit: April 17, 2021, 06:03:39 am by Ian.M »
 
The following users thanked this post: techman-001, Tagli

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Microcontrollers for beginners
« Reply #22 on: April 16, 2021, 04:52:30 pm »
* The Arduino hardwere developers have had a history of making questionable design choices and mistakes.  The most widely known one is the 0.16" gap between the two digital headers on the Uno, which makes it excessively awkward to use 0.1" pitch protoboard for a shield, and has been inherited by every full sized successor Arduino.

Maybe it is a very clever solution to the problem of shields being plugged in backwards.  Sounds like good engineering to me!

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12863
Re: Microcontrollers for beginners
« Reply #23 on: April 16, 2021, 05:06:22 pm »
Maybe, but it would be interesting to see the rationale for that rather than keying headers by omitting male pins and using blocking inserts in the female side, all on a 0.1" pitch.   However I suspect that the history of that decision is either long lost, or at best vaguely remembered with no paper-trail . . .
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Microcontrollers for beginners
« Reply #24 on: April 16, 2021, 05:07:14 pm »
Im actually still a student and am trying to get into professional electronics field, not just a hobbyist

You want to look at your regions employers job adverts and see what  they require for programmers/micro design etc, also ask around your college as they should know what the local firms want student to learn.
Nothing to stop you knocking on their doors and seeing if they have any trainee openings.

While Assembly code is very good at helping you understand the workings of the micro, few companies will expect their staff to use it.

You can run Assembly code direct from the Arduino, this link has a simple flashing led demo, which will give you some idea of how it works and how to use the datasheets, though it will initially seem totally different. Lots of other sites for AVR assembly.



https://www.instructables.com/Command-Line-Assembly-Language-Programming-for-Ard/


Sure other member will be able to give you more guidance....
 
The following users thanked this post: M.Zohaib Usman

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: Microcontrollers for beginners
« Reply #25 on: April 16, 2021, 05:27:03 pm »
Maybe, but it would be interesting to see the rationale for that rather than keying headers by omitting male pins and using blocking inserts in the female side, all on a 0.1" pitch.   However I suspect that the history of that decision is either long lost, or at best vaguely remembered with no paper-trail . . .

You seem to be blowing this out of proportion. Keying headers mean additional cost, even if it's not much, and protecting boards meant for beginners was probably considered more important than allowing more advanced people to design their own "hats" with proto boards.

You seem to be missing the point of the Arduino boards. They are not primarily meant for people able to fully wire a custom PCB, even if just on a proto board, or even solder anything for that matter. Most users are probably just using them with Dupont wires and ready-made additional breakout boards and otherwise ready-made "hats".

Again, more advanced users still willing to use the Arduino ecosystem - which I'm not sure is a good idea, but to each their own - can use a myriad of alternative Arduino-compatible boards with much more powerful MCUs than the original ones on the Uno form factor, and usually with perfectly standard 2.54mm pins (on all those "feather"-like boards.)
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Microcontrollers for beginners
« Reply #26 on: April 16, 2021, 05:27:32 pm »
How else should i start then? i need your opinion

Do you have the hardware knowledge and the coding skills to write at the bare metal level?  If so, rock on!  If you stay with the Atmel ATmega style devices, you will use C and avr-libc.

http://www.nongnu.org/avr-libc/user-manual/modules.html

You should Google around for projects using the ATmega328 and avr-libc.  Duplicate them...

Arduino is denigrated because it makes things easy for beginners.  Usually by experts who have been coding hardware for decades.  And who says the code is bloated?  Have you done a project where you have run out of room?  Sure, it's possible, but unlikely for newcomers.  Unless they try to solve world hunger on a uC using Deep Learning.

The issue with Arduino is simple:  Can it solve the problem at hand easier than any other solution?  Very likely!  Everything that can be done with an Arduino has been done and the project is out on the Internet.  Are they going to qualify for the Nobel Prize?  Probably not.

The other day I was looking at the reference manual for some device (I have forgotten which).  It was over 4,000 pages and there will be a test later.  Sometimes quick and simple is the way to get things done.  No, I wouldn't be expected to know all 4,000 pages but I would need to know some significant percentage just to get started.  Things like turning on the power to peripheral devices and setting up clocks is a true learning experience, fraught with frustration.

Starting with a new platform, it might as well be ARM.  All the big kids are using them and there are many choices.  There is even a platform that serves a large number of boards and it's called mbed.  Now is the time for all the online toolchain haters to come out... 

You don't actually have to use the online toolchain, you can download the libraries and use a local toolchain.  And, it's true that you won't have a debugger but after 50+ years of single stepping code, I think that is the least effective way to debug known to man.  Printf() is a far better solution and it is portable across a lot of platforms.

One cool thing about online toolchains is that you only need a browser to program the device no matter where you are.  Cloud computing I suppose.

https://os.mbed.com/

Look in the hardware tab for a variety of boards that support the mbed way of doing things.  Here's a nice little Arduino shield compatible board with a CPU having 2MB of flash and 1MB of RAM (but read the fine print, only 864 kB of RAM is user RAM...  Based on the dual row edge connectors, it doesn't seem this board is particularly breadboard friendly.

https://os.mbed.com/platforms/ST-Nucleo-H743ZI2/

Do not expect the simplicity and handholding of Arduino when you move to these other platforms.  Sample projects just might not be as readily available.  There are MANY other boards that support the 'mbed' concept.  Pick something and start coding.

I like the LPC1768 incantation because it IS breadboard friendly.  It doesn't have as much IO but all I need to add for TCP/IP connectivity is a MagJack.  See my daughter card, attached.  All I have to do is include the TCP/IP library in my project and it's off to the races.

ARM is the present RISC-V is coming on strong and may play a big role in the future.  The one thing we can be sure of is that things will change.
« Last Edit: April 16, 2021, 05:56:19 pm by rstofer »
 
The following users thanked this post: M.Zohaib Usman

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Microcontrollers for beginners
« Reply #27 on: April 16, 2021, 05:51:38 pm »
Industry is not going to use the Arduino.  They might use the ATmega family of chips (hence avr-libc and gcc) but probably not.

Today everything is about ARM.  The older ARM-7TDMI chips were fairly easy to learn but they are pretty much obsolete.  The PSOC6 I referenced above has an ARM M0 and M4 core.  The videos show how to set up everything from the Cypress toolchain.  Cypress has some very good videos.

If you learn how to work with an ARM M4, for example, you will be pretty close to knowing how to work with all the ARM based chips with the exception of the included peripherals.  They will change between manufacturers/devices.

Get an ARM <anything> and study hard.  Sleep with the Reference Manual under your pillow.  It may not help but it probably won't hurt.  At some level of engineering, you will need to know everything in that manual.

Maybe ST tutorials can help:
https://www.st.com/content/st_com/en/support/learning/stm32-education.html

There are sample projects at the mbed.org site as well.  Google has a TON of information.

The ARM 7TDMI is a dead issue but here is a site that demonstrates ALL of the peripherals for the LPC2148

http://www.jcwren.com/arm/

Here's the Reference Manual (actually, it's just a web page, there is a link to download the manual)

https://developer.arm.com/documentation/ddi0210/c/

It's only 268 pages, perhaps that's why I liked the chip.

How to start?  Start with ARM <anything> and the chip vendor's toolchain.  Yes, this will result in bloat but it's a place to start.

 
The following users thanked this post: M.Zohaib Usman

Online woofy

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: gb
    • Woofys Place
Re: Microcontrollers for beginners
« Reply #28 on: April 16, 2021, 07:26:01 pm »
Im actually still a student and am trying to get into professional electronics field, not just a hobbyist
Don't choose a microcontroller because you think that's the one that will impress an interviewer, and don't abandon the AVR chips because you think they are hobbyist devices.
Choose a chip because that's the one you want to play with at the time, and try others as often as you like.
Knowledge of X architecture may be icing on the cake but on its own will not get you a job. I'll tell you what will get you a job. Ability and enthusiasm.
So pursue your hobbies. Ones that electronics and microcontrollers can help with.  That may be music, robotics, metal detecting, home automation, anything really. Build gadgets and devices for fun and to be useful to you.

It doesn't matter if you learnt processor X and the prospective employer uses processor Y.  When you go to interviews, speak with enthusiasm what you've done. I promise you that is what will impress the interviewer.
And one more thing, 12 years ago I did employ someone who was using an arduino for midi control. I saw the opportunity to expand our abilities and he is still with us.
 
The following users thanked this post: M.Zohaib Usman

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: Microcontrollers for beginners
« Reply #29 on: April 17, 2021, 02:02:13 am »
Maybe, but it would be interesting to see the rationale for that rather than keying headers by omitting male pins and using blocking inserts in the female side, all on a 0.1" pitch.   However I suspect that the history of that decision is either long lost, or at best vaguely remembered with no paper-trail . . .

You seem to be blowing this out of proportion. Keying headers mean additional cost, even if it's not much, and protecting boards meant for beginners was probably considered more important than allowing more advanced people to design their own "hats" with proto boards.

You seem to be missing the point of the Arduino boards. They are not primarily meant for people able to fully wire a custom PCB, even if just on a proto board, or even solder anything for that matter. Most users are probably just using them with Dupont wires and ready-made additional breakout boards and otherwise ready-made "hats".

Again, more advanced users still willing to use the Arduino ecosystem - which I'm not sure is a good idea, but to each their own - can use a myriad of alternative Arduino-compatible boards with much more powerful MCUs than the original ones on the Uno form factor, and usually with perfectly standard 2.54mm pins (on all those "feather"-like boards.)

On the other hand Ian.M kept his criticism of the Arduino strictly to the hardware, and his opinion is as valid as yours or mine.

Personally I find attempts to ascribe far reaching engineering foresight to a product that is clearly a WOFTAM to be quite funny.

Even after all my negative Blue Pill rants I think it has more reason to exist than the 'Arduino ecosystem'  but then that's only my own opinion.


 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Microcontrollers for beginners
« Reply #30 on: April 17, 2021, 03:56:46 am »
I keep saying the PIC16 are only 35 intructions, easy to learn if you want to.
Plus very simple hardware, few registers to touch for making everything work.
Also, you have the xc8 compiler, it's very much the same as the old Hi-Tech (Microchip bought it), works very nice.
People always complain that C is not good on these, but I've seen the generated assembly and it was pretty nice.

Not everything is perfect though, I remember programming a PIC24 with Microchip's C30 compiler (Now called XC16).
I had to multiply and divide in a fast interrupt, and the datasheet stated that it had a fast hardware divider and a single cycle multiplier.
Well, that didn't work. I was losing interrupts, causing overlapping, overflows... when I debugged it, I noticed it was using 450 clocks only in the divide operation.
After a lot of fiddling around, I saw that in the assembly there were no instructions for the divider! It jumped to a classic divider loop.
At least the C compiler manual was good and well explained, I quickly found the built-in wrappers to call the low level hardware within the C code.
And it went down to 22 clocks!

Althought in free mode there are no optimizations. The last version that I know was it could be made "free" was the 1.41.
Plus the good thing is that as you learn, you can go for faster and enhaced families pic18, pic24... it's not like night and day, you get used to them pretty fast.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #31 on: April 17, 2021, 05:28:39 am »
I keep saying the PIC16 are only 35 intructions, easy to learn if you want to.
Plus very simple hardware, few registers to touch for making everything work.
Also, you have the xc8 compiler, it's very much the same as the old Hi-Tech (Microchip bought it), works very nice.
People always complain that C is not good on these, but I've seen the generated assembly and it was pretty nice.

Hey, maybe you could do me a favour?

I've got a silly little benchmark that I've run on a ton of different CPUs, ranging from 8 bit AVR, though all kinds of ARM stuff, to i7 and Threadripper and Zen and Xeon.

Mostly I've run the tests myself on things I've had access to but around a year ago eevblog members submitted a number of other results on things I don't have, such as esp32, esp8266, BluePill, BlackPill, and a chpKIT Pro with PIC32.

So I've got PIC32 in there, but no traditional 8 bit PIC.

Do you think you could compile and run my benchmark on a 8 bit PIC? That would be cool.

The code size is very small -- the actual benchmark part ranges from 178 bytes to 348 bytes on different CPUs with most around 200 to 250 bytes. Plus you ideally need some way to do printf() and calculate the number of clock cycles used, but failing that, toggling a GPIO pin and measuring the time externally would be fine too.

The RAM use is exactly 8000 bytes for two arrays (4000 bytes each) plus another 4 byte global and 12 bytes of local variables in the benchmark function and a similar amount in main, and whatever minimal stack you need -- so well under 8K (8192 bytes).

I'm not familiar with PIC and couldn't immediately find a PIC16 with 8K of RAM -- they seem to top out at 4K. However there are a ton of PIC18 with 8K for  under $3 in a 28 DIP package, so I assume you'd probably have one?

The clock speed is 64 MHz, so they look pretty speedy.

http://hoult.org/primes.txt
 

Offline pqass

  • Frequent Contributor
  • **
  • Posts: 726
  • Country: ca
Re: Microcontrollers for beginners
« Reply #32 on: April 17, 2021, 05:49:17 am »
* The Arduino hardwere developers have had a history of making questionable design choices and mistakes.  The most widely known one is the 0.16" gap between the two digital headers on the Uno, which makes it excessively awkward to use 0.1" pitch protoboard for a shield, and has been inherited by every full sized successor Arduino.

Maybe it is a very clever solution to the problem of shields being plugged in backwards.  Sounds like good engineering to me!


Maybe, but it would be interesting to see the rationale for that rather than keying headers by omitting male pins and using blocking inserts in the female side, all on a 0.1" pitch.   However I suspect that the history of that decision is either long lost, or at best vaguely remembered with no paper-trail . . .


Nah, it was f*kup.   See response from Dec '09:  https://electronics.stackexchange.com/a/941 

"I got to meet Massimo at Flourish Conf in Chicago this year...
Turns out, the actual reason for the odd pin spacing was an error in the original CAD/gerber file. So yea, the odd pin spacing was completely unintentional. Massimo also mentioned that there was a proposal to remove the odd pin spacing starting with the Duemilanove, Mega and future models (a so called "restart"), but was voted down in favor of reverse compatibility with old shields, etc."




 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Microcontrollers for beginners
« Reply #33 on: April 17, 2021, 05:53:01 am »
On the other hand Ian.M kept his criticism of the Arduino strictly to the hardware, and his opinion is as valid as yours or mine.

Personally I find attempts to ascribe far reaching engineering foresight to a product that is clearly a WOFTAM to be quite funny.

Even after all my negative Blue Pill rants I think it has more reason to exist than the 'Arduino ecosystem'  but then that's only my own opinion.

You seem to have an extreme hatred for a platform that despite its warts, arguably almost single handedly saved the electronics hobby. There was a period I remember in the 90s and early 2000's where it was looking like the hobby was on life support. Heathkit had recently gone out of business, Eico, Knight, Dynaco and many others were long gone by then. Radio Shack had become cell phone and crappy RC toy shack, Active Electronics (now gone) was struggling to stay afloat, the well known surplus shops of the old days were dropping like flies, hamfests were drying up and going extinct, it was really bad. Microcontrollers existed, people were using PICs and AVRs but it was a niche thing, pretty much only people who were already engineers.

Then along came Arduino and it caught on like wildfire, the electronics hobby came roaring back, hacker and maker spaces began popping up, annual maker faires popped up, tens of thousands of new hobbyists got into electronics and started building all sorts of innovative stuff. Countless kids got started doing embedded programming at a young age and by now many of those have gone on to careers in engineering. I mean what's so wrong with all that? Frankly you sound a bit like one of those stereotypical old geezers who is angry that kids these days have it too easy and that back in the day you walked to school naked in a blizzard, uphill both ways and liked it just fine. To say the entire ecosystem has no reason to exist is just utter nonsense, the Arduino ecosystem is immensely popular, a smashing success by any measure that has allowed vast numbers of people to create things, some of them incredibly cool and creative, that a great many of them never would have been able to create without some sort of widespread and very easy to use platform. The software is free, the hardware is cheap as dirt and nearly as common. It's not aimed at professional engineers developing commercial projects but even so a lot of actual engineers will pull one out to whip up a quick proof of concept.

I really don't understand the thinking that leads one to believe that an extremely easy to use platform with dirt cheap widely available hardware, a very low barrier of entry and a tremendously huge library of existing projects, code and drivers for all manner of things is a bad thing. Doubly so when you can program it in C, the defacto standard language for embedded programming today, or even assembler if you really want to.
 
The following users thanked this post: retrolefty, brucehoult, WattsThat, pqass

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #34 on: April 17, 2021, 06:20:13 am »
Hear hear! Agree 100%.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #35 on: April 17, 2021, 06:37:11 am »
In the mid 2000s I'd been a professional programmer for 20+ years already, on everything from super minis down to my then current job writing a compiler and low level libraries (threading, exception handling, hash tables etc) for use in embedded systems. most of them using ARM7TDMI.

I wanted to get into doing my own embedded programming projects at home, but it seemed incredibly daunting to get started. One of the most popular things was called "BASIC Stamp" which just seemed like a preposterous idea. Was it possible to avoid BASIC and program the underlying PIC directly? I had no idea. It certainly didn't seem easy.

Everything else available seemed to be prototyping boards for professional engineers priced $500+ (if not $1000+), with as far as I could tell proprietary toolchains costing even more. And needing specialised debug and programming hardware.

And then three things happened within a maybe two year period, at most:

- Arduino (I think it was first)
- Mbed
- Beagleboard

Being able to use the standard GNU toolchain and power and program the board from USB was *huge*. And the prices very reasonable.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Microcontrollers for beginners
« Reply #36 on: April 17, 2021, 06:45:44 am »
Ah the BASIC Stamp, I never did have one of those but I remember thinking it was cool when I was a kid back in the early 90s or whenever that came out. It was expensive, seems like it cost around $50 which was quite a lot of money back then. Worse yet, over the 10 or 15 years they sold those things the price never dropped. I think it was the Arduino that finally killed off that overpriced and slow performing Stamp, which IIRC didn't have a compiler and ran interpreted code.
 

Offline Kerlin

  • Regular Contributor
  • *
  • Posts: 181
  • Country: au
Re: Microcontrollers for beginners
« Reply #37 on: April 17, 2021, 06:47:34 am »
Hear hear! Agree 100%.

Totally agree. Arduino is tops for beginners.
Many posters have already said you can program with the Arduino IDE in C which means you can do bit manipulation and Boolean operations to registers and therefore bare metal this includes ARM devices.
Despite this posters then come up and say you cant.
Common problem here is lack of reading comprehension - read it you are misleading others.
« Last Edit: April 17, 2021, 07:11:05 am by Kerlin »
Do you know what the thread is about and are Comprehending what has been said ?
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14210
  • Country: de
Re: Microcontrollers for beginners
« Reply #38 on: April 17, 2021, 06:53:44 am »
For the start it help if the hardware part is reliable. So I would not recommend a blue pill for the start. As a beginner I would not want to chase HW bugs and incompatible versions. There are enough SW bugs to deal with.
So for the start a ready made board may be a good idea.
In this sense a Arduino hardware from a reliable source (no the cheapest clone from china) may not be so bad - however the software side is really trying to add too much abstaction. Depending on the knowledge this may be Ok but can also be more confusing than it helps.

The personal likes on the IDEs are different - it is not just the decission on a µC but also about the IDE and compiler. Initially one will learn more about the IDE than the µC.

When starting with assembler / bare metal, the AVR  is still a good starting point. The erratas are relatively short and the periphery is relatively simple.
The 8 bit PICs are quite confusing with page switching - nothing one really needs to learn and essentially all others avoid it.

When starting with C, the actual choice of µC is less important and one may as well start with some ARM board. One usually still has the question of bare metal register access and use of some hardware abstraction layer.
 At least with ARMs some abstraction is not so bad as the init part can be quite confusing and long. It is possible to combine it - use the HAL for initialization and direct register access later on - so it is no a strict black or white.
 

Offline pqass

  • Frequent Contributor
  • **
  • Posts: 726
  • Country: ca
Re: Microcontrollers for beginners
« Reply #39 on: April 17, 2021, 06:56:39 am »
...Active Electronics (now gone) was struggling to stay afloat, the well known surplus shops of the old days were dropping like flies, hamfests were drying up and going extinct, it was really bad. Microcontrollers existed, people were using PICs and AVRs but it was a niche thing, pretty much only people who were already engineers.  ...

Yeah, I bought a windowed PIC16C63 from Active in the early naughties. Raring to go but I had no help except the datasheet and not much else. The mood waned and it's been sitting in a box since. Ten years ago I discovered the UNO and have been using a mix of Arduino libraries + my own register fiddling code.  It's a good way to get familar with the chip; get it running fast then exploring each peripheral at your own pace. But especially helpful are the various tutorals on SPI, PWM, steppers, displays, etc.

After the UNO, it didn't take me long to buy blank '328s from Digikey, flash Optiboot using the UNO as a programmer, make my own MAX232-TTL converter and I've since been embedding a '328+3caps+1res+1xtal in a dozen projects.  Boy do I wish I had the whole ecosystem when I started with RadioShack, Forrest Mims and 555s in the '80s.
 

Offline Kerlin

  • Regular Contributor
  • *
  • Posts: 181
  • Country: au
Re: Microcontrollers for beginners
« Reply #40 on: April 17, 2021, 06:59:49 am »
You dont have to use the Arduino software abstactions.
The Arduino IDE can be used in pure C++ or C or even assembler.
Hello, hello, YET again - many have already said this.
You can use them to a get start but only if you want.
« Last Edit: April 17, 2021, 07:08:07 am by Kerlin »
Do you know what the thread is about and are Comprehending what has been said ?
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #41 on: April 17, 2021, 07:05:48 am »
Exactly. Interpreted BASIC. On a microcontroller with basically no RAM. For $50.

If you could stretch to around $100 (by 2008 or so, before Arduino, Mbed, Beagleboard came out) then you could get a WRT54G WiFi/Ethernet router and reflash it and run actual Linux on the MIPS CPU inside. By that time they'd already replaced the original model (from 2003 or 2004 or so?) with a lower cost one, but the hobbyist movement using them was already so large that they retained a hackable version under the model name WRT54GL (for Linux).

If I recall, they have a 200 MHz MIPS CPU, 16 MB RAM, 4 MB flash, and I think 16 GPIO pins of which a handful were not used for something already.

You can still buy them brand new today for $39.99

https://www.amazon.com/Linksys-WRT54GL-Wireless-G-Broadband-Router/dp/B000BTL0OA
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Microcontrollers for beginners
« Reply #42 on: April 17, 2021, 01:23:24 pm »
Hah I'll check what I have lying around. It's been years since last time.
I doubt I have any 8 bit Pic with more than 1kb RAM... I do have some pic32 around, but that's a different story.
« Last Edit: April 17, 2021, 02:45:52 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Jan Audio

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Microcontrollers for beginners
« Reply #43 on: April 17, 2021, 01:56:29 pm »
If you start with 8bit  PIC many things in the manual and online are for ASM programming, just ignore.
On microchip forum you can get good help.

Arduino has Atmega inside if i am right.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #44 on: April 17, 2021, 02:33:06 pm »
Hah I'll check what I have lying around. It's been years since last time.
I doubt I have any 8 bit Pic with more than 1kb RAM... I do hace some pic32 around, but that's a different story.

Maybe I'll just have to buy one. I can afford $3 :-)

Seems it's easy enough to set up one of those wonderful flexible Arduinos to program a DIP PIC18F on a breadboard -- only needs some jumpers and 4 non-critical value resistors.

https://www.instructables.com/how-to-program-a-PIC-18F2550-or-18f4550-with-Ardui/
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: Microcontrollers for beginners
« Reply #45 on: April 17, 2021, 02:46:54 pm »
I recommend not going that way. It will be painful.
Get a pickit and feel the power of debugging your code.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline snarkysparky

  • Frequent Contributor
  • **
  • Posts: 414
  • Country: us
Re: Microcontrollers for beginners
« Reply #46 on: April 17, 2021, 02:50:43 pm »
start with pic24 series.  No bank switching like 8 bit pics and they are powerful chips.

You can get the free MikroC compiler in demo mode.  Only need to buy a pickit programmer.
 

Offline Jan Audio

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Microcontrollers for beginners
« Reply #47 on: April 17, 2021, 04:00:22 pm »
That bank-switching is exactly what i mean you can ignore if you program C language.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12863
Re: Microcontrollers for beginners
« Reply #48 on: April 17, 2021, 04:20:32 pm »
Also, why would you use MikroC which notoriously lacks MPLAB X integration and all its libraries are closed source, when you could be using the appropriate Microchip  XC compiler for your chosen device in in Free mode, with full integration with the Microchip MPLAB X IDE, and source availability for all peripheral libraries, and for all except XC8 the C standard libraries?   Look at the respective limitations and licence restrictions of MikroC's demo mode and XC8/16/32's Free modes, and the choice is a no-brainer in favor of XC even if you discount the MPLAB integration issue and lack of library source access.
« Last Edit: April 17, 2021, 04:23:27 pm by Ian.M »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Microcontrollers for beginners
« Reply #49 on: April 17, 2021, 05:15:27 pm »
That bank-switching is exactly what i mean you can ignore if you program C language.

But it consumes a lot of flash and, of course, takes time to execute.  You can't avoid it, it's part of the architecture but at least in assembly language you can limit the impact.

It's worth the time to just look at the emitted assembly code.
 
The following users thanked this post: Ian.M

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: Microcontrollers for beginners
« Reply #50 on: April 17, 2021, 05:34:52 pm »
.
« Last Edit: August 19, 2022, 04:23:25 pm by emece67 »
 
The following users thanked this post: M.Zohaib Usman

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14210
  • Country: de
Re: Microcontrollers for beginners
« Reply #51 on: April 17, 2021, 08:11:00 pm »
The STM nucleo boards are relatively cheap and they include the programmer / debug interface. So no other hardware needed. Most of them are not really breadboard ready (e.g. 2 row pin headers) - in this aspect the blue pill is easier, if one gets a known good version.

The main reasons to use ASM with a 8 bit µC is to get cycle accurate timing and a little more speed if really needed. With an ARM or similar high performance µC with extra buffers / chache even ASM programs are not that predictable anymore and the speed is most of the time higher than an AVR programmed in ASM. So less need to use ASM with an ARM. The initiallization is quite complicated, to even a simple program gets quite long  and thus less attractive to use ASM.
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: Microcontrollers for beginners
« Reply #52 on: April 17, 2021, 09:55:41 pm »
.
« Last Edit: August 19, 2022, 04:23:32 pm by emece67 »
 

Offline landperm

  • Newbie
  • Posts: 1
  • Country: au
Re: Microcontrollers for beginners
« Reply #53 on: April 19, 2021, 02:56:41 am »
Has anyone heard of BCX variants of STM32 devices?

For example, an STM32F1BCXVC would be the same as STMF103VC...
 

Offline DIYGUY Chris

  • Contributor
  • Posts: 41
  • Country: us
Re: Microcontrollers for beginners
« Reply #54 on: April 19, 2021, 10:18:54 pm »
I doubt that initialization is more easier than AVRs ! I've been playing with AVRs since long long time and the registers manipulation is far easy than ARM MCUs, also I do prefer RISC architecture MCUs  :)
The problem with the Nucleo is the lack of pre-set libraries and the setup of I/O ports depend on the package that you download for the CUBEMX (for sure if I'm not the only one who configure the I/O port by CUBEMX  :D )
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #55 on: April 19, 2021, 11:35:46 pm »
I doubt that initialization is more easier than AVRs ! I've been playing with AVRs since long long time and the registers manipulation is far easy than ARM MCUs,

I think that's the general opinion, justifiably so.

Quote
also I do prefer RISC architecture MCUs  :)

I don't get that part.

Compared to what? ARM, AVR, and PIC are all RISC.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Microcontrollers for beginners
« Reply #56 on: April 20, 2021, 10:01:10 am »
I don’t think that the 8bit PICs qualify as “RISC” in the modern usage of the term.  (Maybe not CISC, either.  Just “simple” ac/memory CPU’s.)
AVRs are closer, except for all those special IO instructions.


As for the original question...  by all means continue using your Arduino, only start paying more attention to its avr-ness.  Read the arduino source code and figure out what there is to criticize about it, and then write better versions, or other code.  Skip the arduino functions in favor of new code.  It’ll always be a comfort to have the arduino funtions to fall back on.


Then get an xplained mini so you can play with microchip studio and an actual debugger.


The get a dramatically different board (ti launchpad, espXX, maple mini, some samd5x board or risc-v), still supported by arduino, and figure out how they are different.  See what is means that arduino support for rPi Pico uses arm-mBed-os...  build software for each of the boards with the vendor’s ide/sdk instead of Arduino.  And then using only cli tools.


Then you’ll  be getting somewhere.



 
The following users thanked this post: Ian.M

Online woofy

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: gb
    • Woofys Place
Re: Microcontrollers for beginners
« Reply #57 on: April 20, 2021, 10:51:36 am »
The I7 is a CISC processor, or is it? It's actually a RISC processor interpreting the x86 instruction set. Is that really different to a Z80 running its instructions via microcode.
The terms RISC and CISC, with their loosely defined ever evolving blurred definitions, should be consigned to the annuls of history.

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #58 on: April 20, 2021, 02:23:10 pm »
I don’t think that the 8bit PICs qualify as “RISC” in the modern usage of the term.  (Maybe not CISC, either.  Just “simple” ac/memory CPU’s.)
AVRs are closer, except for all those special IO instructions.

Oh, I think PICs are certainly RISC. Not a very *good* RISC, but that's another issue. The instructions are all the same length and take the same amount of time to execute. Arithmetic is only between registers I believe -- they just have rather a lot of registers (32 or 128) and sometimes no RAM. And addressing the RAM is weird (similar to 8051 actually).
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #59 on: April 20, 2021, 02:26:22 pm »
The I7 is a CISC processor, or is it? It's actually a RISC processor interpreting the x86 instruction set. Is that really different to a Z80 running its instructions via microcode.
The terms RISC and CISC, with their loosely defined ever evolving blurred definitions, should be consigned to the annuls of history.

This is not correct.

RISC and CISC are characteristics of instruction sets, not of implementation.
 

Online woofy

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: gb
    • Woofys Place
Re: Microcontrollers for beginners
« Reply #60 on: April 20, 2021, 03:27:03 pm »
Oh, I think PICs are certainly RISC. Not a very *good* RISC, but that's another issue. The instructions are all the same length and take the same amount of time to execute. Arithmetic is only between registers I believe -- they just have rather a lot of registers (32 or 128) and sometimes no RAM. And addressing the RAM is weird (similar to 8051 actually).
Same length in the PIC16, but not the same execution time. They take 1 or 2 cycles (4/8 clks). In the PIC18 they are not even the same length, taking 1 or 2 words.

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Microcontrollers for beginners
« Reply #61 on: April 21, 2021, 08:25:23 am »
Quote
I think PICs are certainly RISC. ...  Arithmetic is only between registers I believe -- they just have rather a lot of registers (32 or 128) and sometimes no RAM.
I think you've been mis-led by the somewhat weird (archaic) naming conventions used on the 8bit PICs.

A PIC has one general purpose register, an accumulator "W" ("Working Register")And it has a RAM space that includes general purpose memory, which they call "General Purpose Registers", as well as what they call "Special Function Registers" that do peripheral-like things.

"Real Math" (Add, subtract, OR, AND, XOR) occurs only between the W and one of the memory locations, and the result can be stored in either location.  Instructions are wide enough to address a substantial number of the memory locations (up to 512 at a time on PIC18) with the rest reachable via bank switching.  But I'd say that they're definitely more like memory than registers (for instance, there are no instructions that operate using two GPR locations.)

In addition, there are a large number of "simpler, single-operand, operations" that can be done on any memory location.  INC, DEC, (constant)Bit tests and clears, etc.  Things that are very handy for a microcontroller to be able to do, but not enough (IMO) to make them "registers."  And not very RISCy.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: Microcontrollers for beginners
« Reply #62 on: April 21, 2021, 11:55:17 am »
Quote
I think PICs are certainly RISC. ...  Arithmetic is only between registers I believe -- they just have rather a lot of registers (32 or 128) and sometimes no RAM.
I think you've been mis-led by the somewhat weird (archaic) naming conventions used on the 8bit PICs.

A PIC has one general purpose register, an accumulator "W" ("Working Register")And it has a RAM space that includes general purpose memory, which they call "General Purpose Registers", as well as what they call "Special Function Registers" that do peripheral-like things.

"Real Math" (Add, subtract, OR, AND, XOR) occurs only between the W and one of the memory locations, and the result can be stored in either location.  Instructions are wide enough to address a substantial number of the memory locations (up to 512 at a time on PIC18) with the rest reachable via bank switching.  But I'd say that they're definitely more like memory than registers (for instance, there are no instructions that operate using two GPR locations.)

In addition, there are a large number of "simpler, single-operand, operations" that can be done on any memory location.  INC, DEC, (constant)Bit tests and clears, etc.  Things that are very handy for a microcontroller to be able to do, but not enough (IMO) to make them "registers."  And not very RISCy.

I'm completely aware of the above.

The thing that makes something a "register" is not that it is fully general-purpose for arithmetic. There are many CPUs with registers that are usable only or mostly for special purposes. The 8080 and successors are prime examples. All arithmetic takes place only with A or in the case of the extremely limited 16 bit operations, HL. The same with 8051, except the registers are referred to by number not a name. And then there are instructions that work only with specific registers other than the accumulator, such as Z80 LDIR or 8086 MOVSB. They use very specific registers as source and destination pointers and loop counter and no others.

Certainly, I personally prefer instruction sets where you can use any register for anything. But that doesn't make the other kind "not registers".

The thing that makes something a "register" in terms of an instruction set is that there are relatively few of them and they can be addressed using just a few bits that are completely contained in the instruction opcode (or in the case of x86 in the modrm byte, or for 6809 the indexing byte).

As a matter of *implementation* registers are often implemented in a different technology and can be accessed more quickly than memory addresses, and they often form a distinct namespace. But not always. AVR makes the registers available as addresses 0..31 in the RAM address space. So do PIC and 8051. TMS9900 actually stores registers in normal RAM and has just one "true register" that points to the location of the program's registers.


The PIC ISA is completely correct to describe the things that can be named in the 5 bit or 7 bit field in fixed length 12 or 14 or 16 bit instructions (depending on model) "registers".
 

Offline Jan Audio

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Microcontrollers for beginners
« Reply #63 on: April 21, 2021, 04:05:00 pm »
I think you scared the beginner back to arduino.
 
The following users thanked this post: Bassman59

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: Microcontrollers for beginners
« Reply #64 on: April 21, 2021, 04:19:39 pm »
The I7 is a CISC processor, or is it? It's actually a RISC processor interpreting the x86 instruction set. Is that really different to a Z80 running its instructions via microcode.
The terms RISC and CISC, with their loosely defined ever evolving blurred definitions, should be consigned to the annuls of history.

This is not correct.

RISC and CISC are characteristics of instruction sets, not of implementation.

Indeed, RISC and CISC terms only relate to the instruction sets.
Now in "vintage" CPUs, they also tended to imply a certain microarchitecture, but the very example given by woofy shows that it's certainly no longer the case.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf