r/embedded • • 3d ago

What next?

I have experience with the PIC18F4580 ,so I thought it's time to level up and bought 2 development boards, i.e.STM32F407G(Discovery) and STM32F446RE (NUCLEO), my motive is to understand datasheet and try out some protocol and experience how this board differs from the pic, but this boards datasheet feels quite complex,and dont know where to start,can anyone plz give some guidance and thank you in advance ...

3 Upvotes

13 comments sorted by

2

u/rainboww_J 3d ago edited 3d ago

Yeah, compared to microchips datasheets of their 8bitters the datasheet+reference manuals of the bigger cores are a lot. A good way to start is to use cubemx (or cube ide) to generate a project structure for you and use their hal to interface with the peripherals instead of directly accessing the registers yourself. Then you dont have to read the datasheet and rm from start to end and just look at the section about lets say i2c. And even then, if you use hal, you don’t have to understand it all from the get go, the hal just has a function which performs an i2c transaction. Then step by step you can do a deep dive into the parts of the manuals as you go along

1

u/bigpotato8670 3d ago

Okay ,i guess I started in the reverse order, let me do that, thankyou for your insights 🙏

2

u/ventZl CMRX RTOS 3d ago

You don't have to read the datasheet (actually, for STM MCUs you want to read reference manual) as a book. STM RMs (but this applies to pretty much any ARM-based chip in general) are well-structured, so you basically only need to read the introductory chapter describing core features, memory layout, clock tree and interrupts and manual for whatever peripheral you actually intend to work with.

There is "Programmers Manual" available for each CPU family at STM site which describes the programming model of the CPU core itself. Its an essential document to read to understand how ARM-based MCUs work. You only need to read first ~50 pages of it (basically until the ISA description starts). Its well written and you should be able to understand how the CPU behaves just by reading it.

Those two STM32F4s are very similar, so from programmer's point of view they are basically identical, just the peripheral set will be slightly different.

1

u/bigpotato8670 3d ago

I see, thank you for the info....🙌

1

u/InterestingBiggat 2d ago

Blink an LED using only registers first. Then move to UART, it teaches you clocks and GPIO setup.

-1

u/Separate-Choice 3d ago

As a fellow PIC fan..skip the ARM and STM32 stuff..buy a CH32 dev board or 2 and jump to RISC-V….

3

u/rainboww_J 3d ago edited 3d ago

While the chips from wch are nice and riscv is cool, arm is pretty much the industry standard and ST is a huuuuuge part of that. I’ve never seen the ch32’s being used here in products. Stm32’s however were used in all of the projects I’ve done over the years except for one (which used dspic (embedded linux things ignored, although thats also arm most of the times))

1

u/Separate-Choice 2d ago

This forum is just heavily skewed toward STM32 .. there’s an entire world outside the US and Europe you know.. I ship WCH stuff and I know people who do.. he said he wanted to learn not make products yea?

moving from PIC to an arm core is quite a step up especially a proprietary Cortex M4 core… RISC-V is open and the CH32 chips are easier to understand internally as it’s mostly base RISC-V stuff… if his aim is to understand internals and try out different protocols, learning RISC-V internals transfer far better then jumping from 8-bit PIC to Cortex M4… even a cortex M0+ is a big jump…

I have experience with all of them and then some… downvote or not that’s my advice to OP and anyone coming from PIC.. you’ll feel far more at home on a riscv chip than a cortex M4 one….

1

u/rainboww_J 2d ago

Yes that is true. But depending on where you are on the world and if you want to enter the embedded field or not it might be a good idea to keep that in mind. Also, it really doesn’t matter if you use arm or riscv, from a programming standpoint it’s all the same (or you would want to program in bare assembly… while that may be fun thats not really the normal thing to do nowadays). The peripherals from the ch32 series are very similar to the ones on the arm series of wch which are almost a one-to-one replacement of the stm32f series. If their goal is indeed to learn protocols etc one doesn’t need to understand how the core itself works, be it arm or riscv. Also, they asked us how to start with those f4’s, so saying to skip them and just pick another one is not answering their question. I also started with the pic 8 bitters a long long time ago and went to arm just fine. Yes it’s a big step, but I’d argue that a similar size riscv core would have been a step just as big.

1

u/Separate-Choice 2d ago

Well if he realllyyyy wants to learn then assembly is in the mix…recently I was working with the Baochip 1x a relatively new chip.. there was a bug that when you set GCC to O2 the chip bricked..it took looking at the disassembly to realize that at that optimization level the compiler was restructing the instructions differently and causing the chip memory to blow past into a forbidden zone that forced the chip one way counters to increment and brick the chip…

All embedded debuggers, you debug with assembly. If you can’t read assembly then I don’t know what you are doing since debug and trace is a core skill.

Assembly also comes in porting stuff to new chips I’ve ported freertos, NuttX, zephyr etc etc and all require knowledge of assembly also learning how real time kernels etc etc work all require that knowledge…not to mention porting drivers and optimizing stuff for riscv is its own sub discipline right now as we ditch x86 and arm… there are also lots of jobs in the compiler optimization space for riscv..

And if their goal is to learn then yes understanding the core and interrupt modes and handling etc etc IS crucial…

ARM just took down a site that had documentation to aid developers and is a closed proprietary core…

The core unfortunately does matter once you get past the cookie cutter beginner stuff and get into real development..

especially with all the cyber resilient and security conscious wave hitting the industry and CRA coming next year, as people self evaluate etc etc deep core knowledge is crucial.. and you’ll have better luck with an open standard versus a proprietary core unless you have big bucks to fork over..

Yes you could argue that and I’d argue if you used a PIC you’d feel more at home with a RISCV core than the ARM ones.. anyone can argue anything these days..but someone starting with a basic RV32I or RV32E understanding interrupt modes and exceptions etc etc then working their way up into more complex cores and peripherals will fare farrrr better than someone who learns to use a vendor HAL…

and if he does want to explore other architectures after, understanding how more complex cores work would aid a lot with CMSIS and other hundreds of vendors besides STM32…

Not to mention he may want to do some wireless stuff like ble and WiFi etc etc I’d argue that the amazing ESP32s with riscv cores are superior for that in everyway both performance wireless support and cost wise and I’d be MORE inclined to recommend those over a stm32 for a beginner who wants to jump into the deep end anyway..

He bought them yes, but it’s not cast in stone…it’s 2 dev boards…he can pick up a cheap riscv based esp32-c3 for like a dollar have a cycle accurate qemu learn the ins and outs of the chip, have wireless and knowledge that is transferable.. he said it’s difficult so throwing other suggestions isn’t bad either….

Someway along the line on this subreddit specifically embedded engineering turned into stm32 vendor HAL ‘coding’… learn assembly, learn new and open architectures.. that’s what makes a good engineer..

Either way my advice still stands to anyone reading this thread….if you want to get deep into embedded systems get a cheap core that you can explore in depth as open as possible and simple to understand..

Start with the CH32 the cheap ones you can experiment with and brick and understand fully..then get you yourself some high end ESP32s with riscv cores.. skip arm unless someone is paying you a lot of money for a job…

Long live RISC-V. Long live open source.

1

u/rainboww_J 2d ago

The times I had to look at the generated assembly or debug with assembly listings is countable on one hand… realistically you almost never have to. I know colleagues of mine who don’t really understand the inner workings of the toolchain, don’t really understand assembly and still are very capable embedded engineers. Debugging can be done without ever looking at assembly, especially on well established platforms where one doesnt have to port zephyr or freertos to.

And real development? Ive worked on many projects which went to market eventually and time is money, we use hal’s and existing proven toolchains, almost never the newest of the newest without support

And yeah esp32’s are nice and its true the c lineup is riscv, but honestly, they could’ve been arm or even mips. The idf is good enough you don’t need low level stuff to make a good product

I do love risv, I truly do. But in my day to day work I really don’t care what architecture it is, as long as it has good compiler support and a proven hal

0

u/Separate-Choice 2d ago

Depends on where you work on the stack there are capable embedded developers but those are not embedded engineers regardless of what the title says.

And if you are porting an RTOS without looking at the assembly how do you plan on performing the context switch? 👀

If the CPU traps on a bad address or instruction what do you do? Source level debug can’t find that. What about volatile access and critical sections? only assembly can give you that…I would love to go through your code base.. then again you mentioned spend so engineers at the vendors handle that stuff for you..so I guess you do mostly cookie cutter and integration work than enginnering…

Well the thing is at some point someone has to do that. That’s what embedded engineers do so the embedded developers like yourself can work at the HAL level… but if you want to up skill yourself learn embedded engineering as well.. I think eventually AI will be able to do most of the integration work with a well tested and debugged HAL…

Dang, I’m curious though which industry do you work in consumer? Or you an embedded Linux dev?

If your HAL has a bug what do you do!? As someone shipping products you never once had to modify startup assembly?

I know people sent products to market with Arduino. Dosen’t mean they know what they are doing really…especially these days..then again in consumer market that stuff matters lesss..still having your product randomly freeze from memory leaks and edge cases what not is diabolical..

As for zephyr and NuttX and stuff I can tell you never ported those based on your response…lol

As for new chips and peripherals the CH32H417 has USB 3.0 which I was dying for and it’s new…had to debug and write a lot of stuff myself…even in the vendor HAL…. the western vendors are lagging behind there..

Someone gotta do the new stuff. Especially if your goal is learning. You’re an embedded developer and that’s fine I was leading the OP down the path of becoming an embedded engineer. They’re not the same.

Also he used PIC I’m sure he’ll appreciate that CH32vs can run on 5v for porting his legacy designs.. I personally enjoy that for power stuff as it makes driving mosfets easier with the jellybean stuff…

Umm actually they couldn’t do it with mips or arm…licensing and what not and flexibility…like ARM sells profiles so you can’t get a Cortex M with an MMU for example, but Espressif is able to put MMU on microcontroller class device..Baochip as well.. yeaaa..

As an embedded developer I expect you to treat the core like a black box but engineers can’t do that..especially if you’re going for safety stuff… even if you buy stuff someone else did.. I prefer to be the guy selling the stuff than just be an integrator… it’s more fun.. but to each his own…

Yea I already gauged where you work, more cookie cutter embedded software stuff yea?

I don’t know how long you are in the field..but someday you’re going to meet a bug in your HAL or drop down to a lower level for more performance… when that day comes you’ll be glad to be able to work at a lower level..

0

u/rainboww_J 2d ago

Please step from that high horse of yours. Yes they are embedded engineers. You might think that way but lots and lots of others won’t agree with you… You can use an rtos without the need for porting it yourself you know. For lots of vendors there are ports available, sometimes even provided by the manufacturer themselves. As said before time is money so no neither I or someone else in my team will port an rtos themselves. You can make assumptions all you want about my knowledge and work I do, but stop arrogantly looking down at higher level work, it doesn’t look as cool as you think it does…

Yes it’s true that some need to do low level stuff. But come on man, you’re still an embedded engineer if you don’t do that. And no I never ported zephyr and nutx. So what?!? I did port freertos a couple of times on my own time. I also done fpga work both on the firmware and on the hardware side.

But that doesn’t matter. You already seem to know anything and everything about me and everything else. Please continue to belittle everyone around you if that makes you feel good about yourself. But please know it won’t help any newcomers to the field. If someone asks for help you help them so much more with some helpful feedback and pointing them towards their goal instead of boasting about you are a real engineer and anyone else isn’t