2018-06-09 06:42 AM
I understand that programming enterprise software on a 8 core CPU with 4GHz and a simple STM32 MCU is different, nevertheless I would have added a few things to the HAL layer from the beginning:
Wouldn't such things help greatly to get started? And to debug? And make the user experience better? And lower frustrations? And cause proper error messages rather than simply not working?
Or am I missing something.
Note: this post was migrated and contained many threaded conversations, some content may be missing.2018-06-09 07:31 AM
>>I understand that programming enterprise software on a 8 core CPU with 4GHz and a simple STM32 MCU is different, nevertheless I would have added a few things to the HAL layer from the beginning:
I was programming system drivers on multi-core Windows boxes over a decade ago, the STM32 HAL looks like a complete train-wreck in places. Seems to evolved from engineers who coded single threaded 8051 embedded solutions rather than those using Pentium Pro's.
If your brain can conceive more than one thing occurring concurrently I suspect you're already miles ahead.
2018-06-09 07:48 AM
'
Wouldn't such things help greatly to get started?'
this is where an OEM library is often a great compromise (in a good way), as it has to deal with a vast spectrum of programming behaviors, from a 'nanny-state' approach where everything is packaged (Arduino and MBED), to 'you are on your own' approach.
It may very well be the case where MCUs of the future could run an OS that shields the user more or less from the hardware. Your approach is sure reasonable for some applications / some programmer. and will likely be the future.
However, many other people prefer the 'i want to take care of myself' approach.
HAL is somewhere in between, but much closer to your thinking, though not enough I guess.
2018-06-09 08:04 AM
Just a couple of days ago I had to add reading the raw input from an incremental encoder. Now I have those GPIO pins used for both GPIO inputs and inputs to timer in encoder mode. Good that HAL didn't check for 'conflicts'. And yes, our company wants us to use HAL. I'd do fine without any libraries and frameworks.
If handling the HW is such an issue to you, maybe your place is not in the embedded world? The embedded world tends to be mostly dealing with HW. There are also some operating systems available for the processors with some ready-made drivers.
Like
•
Show 0 Likes2018-06-09 09:59 AM
Let me follow up on that. Per my understanding the HAL plus MXCube is the highest abstraction level STM provides. The OEM is no generic library but more use case specific, e.g. Motor Controller for Brushless Sensored Motors.
RTOS etc sits way above that, but actually would deserve support from STM as well as part of the HAL, thinking about it. Yes,
Arduino
& MBED are probably good examples of what I am looking for, except that per my knowledge again, if anArduino
SerialInit() does not set the hardware right but you have to do that and it does not return an error if the hardware is not setup properly, e.g. Pin used for something else as well or register not set.Agreed or is there a gap in my knowledge?
2018-06-09 10:04 AM
Actually, that's a good point. It looks like a hardware engineer listed all the switches and the software programmer than implemented one function call for each switch. That's a bit harsh and wrong but still. What does the enduser want? An encoder up and running. Error messages if the preconditions are not met.
(Didn't want to go into multithreaded programming, that's another level of complexity. Just wanted to say that a CPU as powerful as PCs a few additional if-then-else make no difference whereas in a 16MHz you might want to spare that. But there are solutions for that as well like precompiler directives adding these tests in a debug build only.)
2018-06-09 10:11 AM
Fair point.
How often would people benefit from the test and error messages though compared to how often they would hinder them?
If they hinder you, would you be able to workaround them, e.g. by using the __HAL methods?
Let's compromise, and we add one layer above the HAL and keep the current HAL as it is. Maybe that is the better request.
PS: Your concrete example is not valid. Encoder with GPIO Input and/or external interrupts is just fine. No reason do not allow that. My example was GPIO plus UART on the same pin - that would be more exceptional.
2018-06-09 10:29 AM
Not interrupts. Just reading the pins. That could be used for board testing - even before the encoder is installed.
And I can't see why the same could not be done to serial lines.
And believe me, if a new layer was added, then the managers would require that you to use that. You can't win in these. :D
BTW, just came to mind, there are other situations of similar nature (even if not quite the same). I wrote an RS-485 interface for a F4 board.
I used the serial handshaking line for DE, because the F4 didn't support RS-485.
I also wrote a LED driver chip interface - SPI without any chip select. I used the HW NSS pin as GPIO for latching strobe.
2018-06-09 10:31 AM
While an STM32H7 running at 400-500 MHz with a Double Precision FPU doesn't have the polish of a Pentium or Pentium II, it won't burn my fingers when I press on the top of it.
2018-06-09 10:35 AM
>>
HAL is somewhere in between, but much closer to your thinking, though not enough I guess.
The goals represented quite a reach, the problem there comes when you keep over-promising, and under-delivering.