How far up the code stack should I start? - Page 1
Forum section: electronics / beginners

author: set321go
author_rank: Newbie
timestamp: May 07, 2019, 06:13:16 pm
content: Looking to write a microcontroller application, I'm building a rowing computer so first version is usb, accelerometer, display, sd card. The general concept is read sensor data do some math and store it to memory & display it on screen. At some later time offload the data via usb. The SD card was a shortcut idea to avoid the usb data part on the initial go around. I'm planning to use an STM32F0 to start with. I have a SW background so I'm kinda struggling with the whole 'roll your own' approach for everything.I'm pretty certain I need a bootloader as I want to flash firmware updates via usb. What are my options here? I found OpenBootloader but that was about it, is there anything else worth looking at?I looked around for some kinda OS and came across the concept of RTOS, i think this is probably a bit to much for my needs but is there other maybe less heavy loop/scheduler type frameworks? (i'm hopefully searching for the wrong terms which is why i can't find much)

author: Domagoj T
author_rank: Frequent Contributor
timestamp: May 07, 2019, 06:29:13 pm
content: It would probably help if you told us what is the microcontroller supposed to do.

author: set321go
author_rank: Newbie
timestamp: May 07, 2019, 06:34:46 pm
content: Quote from: Domagoj T on May 07, 2019, 06:29:13 pmGood idea! Updated my post with some details.

author: Jeroen3
author_rank: Super Contributor
timestamp: May 07, 2019, 08:04:05 pm
content: Quote from: set321go on May 07, 2019, 06:13:16 pmThat a lot of things at once, for an F0... as a beginner... It you only have a text display, it's probably fine.An RTOS can help you handle the concurrency of the above tasks. Otherwise you'd have to police yourself that the code doesn't wait somewhere too long and fix interrupt priorities. Which an RTOS can ease for you. But it can also complicate things when you still manage to do it wrong.I've not been using ChibiOS for a while, but they used to be very much oriented around STM32 chips. You might even find compilable STM32F0 SD card examples, that'll ease your job a lot!

author: set321go
author_rank: Newbie
timestamp: May 07, 2019, 08:30:03 pm
content: Quote from: Jeroen3 on May 07, 2019, 08:04:05 pmWell i'm going to attack things in stages and I've already prototyped that setup out on an arduino mkr board.1. Microcontroller talking to accelerometer using i2c2. Add display text i2c3. Add sd card data write over spi4. usb... (not looking forward to this bit).Is an RToS the right term? Or should i be looking for something else to help with interups and scheduling?

author: Jeroen3
author_rank: Super Contributor
timestamp: May 07, 2019, 08:58:28 pm
content: Looks like only the accelerometer is a “realtime” task. For best results you want low jitter on the measurement. This means you could do it with one interrupt, and the rest in the superloop.USB also requires realtime reaction, but this is usually handled in the ISR of the driver.In a superloop you’d be making software timers anyway. An rtos can only help you with this. And then after that you have learned how an rtos works!