STM32CubeMX Advanced Peripheral Setup Explanations???........ - Page 1
Forum section: electronics / general

author: Smokey
author_rank: Super Contributor
timestamp: November 14, 2018, 10:34:14 am
content: tl:dr = Is there an official resource that gives either config examples or at least a detailed explanation for all the peripheral configuration options in CubeMX?

author: Smokey
author_rank: Super Contributor
timestamp: November 14, 2018, 10:36:34 am
content: I'm using STM32CubeMX for the first time in a real project. Simple stuff like GPIO isn't a problem, but and I'm having a hell of a time trying to understand how to set up the advanced peripherals like the timers using the GUI.For those not familiar, there are a lot of options to click through. Here is an example.Mode setup:Then the full setup:It gets even more unclear when you want to set up the timer as an encoder interface. Setting "Combined Channels" = Encoder mode greys out channels 1 and 2 with the text "Disabled", which are actually the ones that get used in this mode. Channels 3 and 4 are still shown as valid options but are unused. This seems really backwards.http://elastic-notes.blogspot.com/p/cubemx-stm32-encoder-interface.html

author: capt bullshot
author_rank: Super Contributor
timestamp: November 14, 2018, 10:50:10 am
content: Without having read and understood the appropriate STM32 controller user manual, the Cube tools isn't too helpful. It just offers a lot of choices according to the register descriptions found in the manuals.

author: Smokey
author_rank: Super Contributor
timestamp: November 14, 2018, 11:34:03 am
content: Quote from: capt bullshot on November 14, 2018, 10:50:10 amI totally agree. Nothing is better than fully understanding the register level configuration. This is not my first embedded system design, but this is the first time using STM32 and a HAL and I figured I'd take advantage of the tools available.I guess my problem is: If the point of the HAL and GUI is to simplify setup and configuration so people don't need to manually define everything at the register level then it sort of defeats the purpose to make people dig through the register level documentation to figure out how to use the GUI.Thinking about it, a configuration wizard is what's missing. Something that steps you through the options with explanations for each option.

author: AndyC_772
author_rank: Super Contributor
timestamp: November 14, 2018, 12:59:31 pm
content: I liken it to a tour guide who is supposed to help you get around in a foreign country.If you can ask them for the correct bus or train ticket for a day's outing, and they're able to buy it and hand it to you, then that's great. They're doing a useful job.CubeMX is more like a guide who responds with "OK, no problem, you tell me exactly what words to say and to whom, and I'll say them on your behalf".It's not helping; you need to learn the local language, and how its transport infrastructure works, for yourself. Once you've done that, you don't need the guide anyway.

author: Smokey
author_rank: Super Contributor
timestamp: November 14, 2018, 01:29:44 pm
content: ¿Donde Esta La Biblioteca?...... alt-168 is the only extended ASCII code I consistently remember

author: richardman
author_rank: Frequent Contributor
timestamp: November 14, 2018, 07:52:10 pm
content: CubeMX and all the ST libs (SPL, HAL, etc.) are basically just veneer on top of the I/O registers. There is no functional abstractions except the simplest cases. So, yes, you will need to RTFM. CubeMX does do a good job showing the clock tree visually though. That's probably one of its most important functions.

author: JVR
author_rank: Regular Contributor
timestamp: November 15, 2018, 10:16:13 am
content: Cube is not intelligent, it is barely a code generator. What it does, is give you a GUI on top of register access, and generates some of the code to instantiate those registers. You are still responsible for connecting lots of different bits together. Once you understand that, Cube becomes a great way to save 3 days of manual pin-planning and coding up register definitions. Does any of Cube's source files ever make it into my production code? Fuck no, they are just there to copypasta from so I don't have to smash a keyboard.

author: Smokey
author_rank: Super Contributor
timestamp: November 16, 2018, 07:26:55 am
content: Quote from: JVR on November 15, 2018, 10:16:13 amIsn't this a shame though? I mean with only a little more work it could be a full on configuration tool based on functionality at a high level. The wizard walk-through is the way to go here.How is Microchip's Harmony in this respect? Does that tool have more intelligence than CubeMX?

author: JVR
author_rank: Regular Contributor
timestamp: November 16, 2018, 09:16:58 am
content: Well yes, but then you have to sit with the support calls. And modern MCU's have so many options to interconfigure peripherals that writing code to iterate every option would be suicide. Its still up to the engineer to have read the documents, and understand the choices he is making, a wizard will never be able to explain the intricacies. And if someone wants that, then they can go back to arduino, where you get spoon fed other people's code, and its undoable if "there is no library for it"As for Harmony, its been ages since I've used it, but from what I remember it is much the same, it saves you keyboard time, it wont write your application for you.

author: diyaudio
author_rank: Frequent Contributor
timestamp: November 16, 2018, 11:23:20 am
content: Quote from: JVR on November 15, 2018, 10:16:13 amCubeMx always gets alot of flak but this is one of the best things it does right the pin mapping and initialization saves a ton of time the pin mapping diagram is really useful as well, its not a bad tool it can do better in other aspects.

author: Smokey
author_rank: Super Contributor
timestamp: November 16, 2018, 08:45:54 pm
content: Quote from: JVR on November 16, 2018, 09:16:58 amThis depends entirely on how big and established the company is. Look at what TI did. They were tired of handling support directly so they made the E2E web forum support system to handle virtually all of their support issues. Post your problem and someone will get back to you in a reply, either community member or TI staff. TI must have figured that they were a big enough and well established enough company with a good enough product that they can pull this off, and I think they are mostly right. Now I don't really like working with the E2E system, but in reality it's not much worse than sending an email to whoever your official support guy was before and waiting for him to get back to you eventually. At least with E2E there was a chance a community member would answer your question as well.So I guess what I'm trying to say is that there are ways around the support issue so it's not a crushing burden. Having CubeMX do intelligent configuration based on functionality would be a game changer and increase ST part usage enough to justify the support.

author: Smokey
author_rank: Super Contributor
timestamp: December 19, 2018, 11:26:14 am
content: Hmm.. STM32CubeMX v5.0.0 was released with a totally new GUI layout, but as far as I can tell no new wizards. Bummer.

author: Cicero
author_rank: Contributor
timestamp: December 19, 2018, 02:04:11 pm
content: Agreed with most of the above.There is no substitute for reading through the manual for anything more than basic setup.But the Cube definitely helps speed up your initial code generation, making sure you've got your pinout correct and can access certain pins with whatever peripheral combination you're using, it so quickly picks up conflicts. Clocks are sorted very quickly and visually.I do find the HAL drivers bloated, and I've often had to jump in and modify them slightly because they restrict certain features, or force certain actions/sequences unnecessarily.

author: Simon
author_rank: Unknown
timestamp: December 23, 2018, 10:54:44 pm
content: Quote from: Smokey on November 14, 2018, 11:34:03 amYep been there. Oh look i can set all this stuff up with a GUI, so i want a PWM output, bam, there's all the code, great, now how do i turn it on, duh! If i have to read the code output to understand how to use it I may as well just read the datasheet and thoroughly understand the registers and write my own initialisation code.