Having trouble picking up new microcontrollers

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ceva156
 
Posts: 1
Joined: Sat Jun 04, 2022 3:01 am

Having trouble picking up new microcontrollers

Post by ceva156 »

I'm about to graduate my ECE program, and wanted to try picking up a new microcontroller on my own. Our university taught using a Arm M4 on the TM4C123 board with Keil and an extensive HAL. I've worked with some other MCUs, but not at the register level.

So I recently got an STM8S Discovery board, and am having trouble with getting set up. I've got some datasheets but I feel like I lack a preliminary collection of C files and documented code for startup. I'm trying to figure out what knowledge I'm missing to comfortably pickup a new MCU.

Should I learn to work with stuff like SDCC? More "bare metal" programming? I honestly was fairly reliant on textbook/course materials to help me write code, and am now suffering for it. Thanks!

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Having trouble picking up new microcontrollers

Post by westfw »

STM8 is sort of a pre-C microcontroller architecture that doesn't come close to being compatible with gcc, so you're pretty much forced to program in assembly language, or a more obscure C compiler.

Putting together a development environment from scratched, based on SDCC, would be an educational exercise, but is probably more painful than necessary, especially if you're at the point where you're mostly interesting in learning about the CPU and chip architectures.

I would suggest starting at https://www.st.com/en/development-tools/stvd-stm8.html and using one of the C compilers they reference (at least one of which has a free version.) There is a standard peripheral library for STM8 that you can download, and it looks like it is written mainly for the IAR C compiler (IAR also has a free size-limited STM8 C compiler and a full IDE that is probably pretty similar to what you've been used to.)

The 2nd architecture is the hardest (especially when it is dramatically different from the first one you learned.)

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Having trouble picking up new microcontrollers

Post by adafruit_support_mike »

ceva156 wrote:Should I learn to work with stuff like SDCC? More "bare metal" programming?
Yes. There are two general classes of programming: framework development and debugging.

A framework is a (hopefully) unified collection of frequently used code. It's designed to save the time and effort of writing bulky low-level code over and over, and to collect mature solutions to subjects where there are lots of subtle ways for things to go wrong. With a good framework you can build reasonably complex programs by gluing existing modules together. Most of the work is just setting parameters to get the specific behavior you want.

Unfortunately no framework is perfect, and a common side effect of getting familiar with one is a growing desire to do things the framework doesn't support. You'll run into edge cases the framework developers didn't expect, and the occasional outright bug in the code. When you run into those, the framework stops being a tool and becomes an obstacle.

That's when you need to know the hardware and the low-level code.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”