MicroController progrmaming books - Page 1
Forum section: electronics / beginners

author: netmonk
author_rank: Contributor
timestamp: May 31, 2020, 08:36:41 am
content: Hello,Im an fresh MCU programmer, since one year, who started with arduino like i guess most of the hobbyist around.I played with teensy,and since few months, i become really fond of esp32 and i start to discover riscV mcu.it happens that now, i feel that arduino sketch are not so much adapted to my needs, and given my next project expectation i need to go deeper into mcu C programming and algorithmic. Im expecting to receive a little black box, and start to use JTAG too.What im looking at is a book describing general concept of MCU programming (io/scheduling) and no so much tied to a specific platform. How to design and architect your code, given all specifics of MCU.Should i use RTOS to build my application on top of it, or should i go pure baremetal, and in this case what are the minimum requirements...I looked on amazon and oreilly, seems most of books are specific to stm32/arm ecosystem. which could lead to some misleading when trying to transpose for esp32 or riscV.So im looking for suggestion about more general books which are going in depth into this kind of topic explaining good practices and most used algorithms for programming MCU.May be it doesn't really exist, may be blog/website could be a better source of information. Im really asking to experimented programmers around what was their sources for building their knowledges.

author: rstofer
author_rank: Super Contributor
timestamp: May 31, 2020, 04:12:20 pm
content: I don't know of any particular book that can help.What I have noticed is that the ARM chips are getting ever more complex with multiple cores (usually of a different type) and increasing horsepower. Even the Teensy 4.1 is now up to a 600 MHz chip and a User Manual that is a concise 3637 pages.Cypress has some great tutorials for their PSOC chips and their toolchain is pretty nice. It still takes a bunch of time to get things working even if you do use their code. But it's doable.Moving backwards to the ARM7-TDMI series chips like the LPC2148 makes things much easier to approach. Look athttp://jcwren.com/arm/This is a much older chip but it is actually possible for mere mortals to understand it at a very low level. The User Manual is a mere 354 pageshttps://www.nxp.com/docs/en/user-guide/UM10139.pdfI haven't spent a lot of time with FreeRTOS but I have played with it on the Cypress PSOC chips but they already have a port of the code and the toolchain sets everything up. I guess if I wanted to play with high end ARM chips, Cypress is about as good as it gets.There's plenty of griping about the ST tools but I have played with them a bit and they seem to work fine. The big complaint is about bloat and that's clearly the case. The alternative is to gut their code to bare bones for a specific processor and see how it works out.Here's what is ridiculous: A simple blinking LED on a Teensy 4.1 takes 14,688 bytes of executable code using the Arduino toolchain. That is absolutely insane! It isn't that much better on any other chip using any other toolchain.In terms of how to architect a large program from scratch, well, that's an advanced topic. It can take years of school to even understand the complexity much less the solution. Yes, implementing FreeRTOS is a good place to start. Not only does it support real-time applications but it cleanly segments code into functional blocks. In many ways, this is encapsulation. A UART process doesn't require periodic calls from main(). Whatever the UART handler does, it is behind a screen and the results are left in a queue.If I were starting with FreeRTOS, I would pick a board/chip for which a port was already available.Check out the PSOC 6https://www.cypress.com/products/32-bit-arm-cortex-m4-cortex-m0-psoc-6

author: netmonk
author_rank: Contributor
timestamp: May 31, 2020, 06:05:47 pm
content: Thank you so much for your reply.I totally understand that there isn't one book for everything.When i started to look at riscV on longan nano, i find this article very interesting :https://vivonomicon.com/2020/02/11/bare-metal-risc-v-development-with-the-gd32vf103cb/But the level is a little bit far advanced than basic blinking led.It's all about bootloader, interrupt table an so on...Which is something totally hidden when coming from Arduino.I was looking to some more normalized book ressource where all those are explained in depth, with an easier learn-curve, than a dense and highly technical blog post.Second point is that ESP32 is natively supporting and provided with freeRTOS, at least when using their official framework (esp-idf).Arduino just hide all the complexity at the cost of limiting both performance, size of cost and access to hw full capacity.

author: ataradov
author_rank: Super Contributor
timestamp: May 31, 2020, 06:10:12 pm
content: I don't think there are definitive introductory books like that.I would just start migrating from your current setup step by step. This way you won't have to figure out as much in one go. Keep the Arduino build environment, but figure out how to program the device using standalone tools. Then keep the arduino build, but don't use any of their libraries. You will end up with a bare-metal code. Now figure out how to call compiler on your own, and you no longer depend on the Arduino.From a practical point of view, it may be easier to learn with more wide spread platform (STM/ARM is a good candidate). The knowledge will easily transpose to other architectures. GigaDevice RISC-V chip is literally their old ARM chip with the core swapped.Also, that is not a bad tutorial, but sure, it is too much to take at once, especially if you want to see the fast result. But with the tutorial, you don't really need to fully understand the code. Just take the code as is and focus on compilation and programming of the device. Once you have that going, it is very easy to experiment.

author: netmonk
author_rank: Contributor
timestamp: May 31, 2020, 08:38:38 pm
content: Thank you Ataradov for your reply,I already have good experience with platform.io and im starting to migrate my arduino sketch to pure esp-idf.i started by rewriting the little i2c scanner and i must say the code is already more "complex"But it's fine.Next is that im going to rewrite my dshot600 controller in pure esp-idf, and i was thinking to try port it also in riscV.my bet is that the more you program the more you fail, the more you debug and the more you learn.