10
\$\begingroup\$

I am going to start with ARM development (after 2 years of AVRs) and have picked up the STM DISCOVERY board with the stm32f4 microprocessor on it.

I have decided to go with eclipse + ARM gcc since I don't like the code limit on Keil and I don't have the money to get a paid version.

Following the tutorials I have installed eclipse along with gcc ARM tools + openocd + make utils etc.

My question is about the 'packages' plugin. Like every beginner, I am confused as to whether to use new STM HAL or the older SPL.

My understanding is that HAL has implemented abstraction to a level where it can be referred to as Arduino equivalent for arm. SPL on the other hand provides just enough abstraction to make coding faster but you still need to deal on chip level.

With this understanding I would like to stick with SPL to understand things better rather than using HAL.

What I would like to know is, does using packages for STM implicitly force me to use HAL? If so, can someone point me on how to use SPL with my setup?

\$\endgroup\$
  • 1
    \$\begingroup\$ "the tutorials" is a bit vague, so I don't know about "the 'packages' plugin" and I have no idea what SPL (STM peripheral library?) or SPCL is. Maybe I'm just not qualified for this question, but working with STM32 for over two years now made me wonder... \$\endgroup\$ – Arsenal Oct 28 '15 at 13:56
  • 2
    \$\begingroup\$ SPL is Standard Peripheral Library, on the other hand I do not know SPCL either. \$\endgroup\$ – Bence Kaulics Oct 28 '15 at 14:02
  • 2
    \$\begingroup\$ The STM preferred and supported way today is to use the STM32CubeMX, which is generating code based on HAL. And I must admit it is pretty handy, although I am not a fan of automated tools as they hide important stuff.. \$\endgroup\$ – Eugene Sh. Oct 28 '15 at 14:41
  • 1
    \$\begingroup\$ Although it should be mostly compatible with other STM32 processor SPL versions, I don't believe ST has SPL for STM32F7. \$\endgroup\$ – Tut Oct 28 '15 at 14:57
  • \$\begingroup\$ Sorry about the SPCL bit. That was a mistake. Still getting used to the acronyms.Also just double checked and my board is stm32f4 variant. Another mistake. Still the general questions stands, how do I use the standard peripheral library with eclipse? \$\endgroup\$ – Ankit Oct 28 '15 at 15:16
6
\$\begingroup\$

The SPL, as I see, has nothing to do with what IDE you are using. You can simply include the relevant modules (e.g. stmf4xx_dma.c and stmf4xx_dma.h) in your project and use the functions exposed (and described very well) in the .c and .h files. In fact I've been learning on the stmf411 nucleo with gcc, openocd and SPL using just the windows command prompt; no IDE. Packages in eclipse probably would force you to use the HAL (since inside the downloaded 'Packages' folder for eclipse, I only see HAL modules).

The HAL itself IMO seems far much layered than necessary. Whereas accessing the registers directly gets tiresome and is hardly readable. The SPL seems just right. clive1, the guru on the st.com forum, also prefers the SPL over HAL. Here's my question on that forum... might be helpful.

Need help with USART on Nucleo stmf411

\$\endgroup\$
  • 1
    \$\begingroup\$ I totally agree with you in that. HAL seems to have gone overboard with the whole abstraction concept. Although with it one would develop programs faster, you would not really learn what exactly is happening which I think is essential for learning and to be future proof. As a test I created a project in uvision and selected legacy support instead of software packs and that seems to have included the SPL files. Also thanks for the link ! \$\endgroup\$ – Ankit Oct 29 '15 at 5:36
1
\$\begingroup\$

I don't have any experiences with HAL,but used SPL many times for saving my times. In my believes Target community of this Embedded processors are 2 groups: First group which are not interested to engaged with hardware layers. Software programmers,usual hobbyists and Arduino ,Raspberry worshipers. if you are in this group seems HAL is good choice for you. Seconds which comes from electronic and hardware community, whom prefer

GPIO_A->PIN &= ~(1 << 15);

to

LED_On(1)

for turning on the LED and want to know what they are doing basically. then if you have in this group and have enough time to reading reference manual and programming manual of your MCU maybe register level programming is another choice. but if you want to decide between only above 2 option: HAL has a better future because of ST' supporting but SPL is a easier way to understanding for a new starter. Maybe this can help http://www.eevblog.com/forum/microcontrollers/stm32-and-their-hal-library/

\$\endgroup\$
  • 1
    \$\begingroup\$ Thanks for the link, interesting read! You are correct, for beginners SPL seems like the better way in order to learn (and this is the way I have also chosen). Btw in your reply it should be LED_Off \$\endgroup\$ – Ankit Nov 15 '15 at 21:20
1
\$\begingroup\$

Get this IDE: System Workbench for STM32 - it's free, based on Eclipse and have both arm-gcc and openocd in one package.

And about libraries: besides SPL and HAL now exist LL. Eache one have some advatages and disadvantages, and you must choose what you need. And as I understand, all of them have experimental status for ST. Below my grades to each of them:

  • SPL: old, cumbersome, no extra ram usage, flexible
  • HAL: actual, cumbersome, extra ram usage, not flexible
  • LL: actual, ligtweigth, no extra ram usage, flexible

Short description for my grades:

  • cumbersome - big flash usage, "super" universal functions for work with periphery
  • extra ram usage - it's about HAL, it have copy of peripheral state in ram located structs and use it everywhere and everytime
  • not flexible - and again about HAL, it have a lot of functions for differents cases, but! most of them are not usable for real devices (peoples try to reinitialize HAL for receive byte by byte from usart >_<, all functions for TIM+DMA are implemented for rewrite TIM register and no any other...)

For a little rehabilitate HAL: it have one big advantage for newbie - it suppoted by STMCubeMX.

EDIT:

I forget about libopencm3 - it's alternate library. I haven't used it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.