cancel
Showing results for 
Search instead for 
Did you mean: 

Standard Peripheral Library vs STM32CubeMX(HAL) library

L C
Associate II

Posted on April 29, 2017 at 17:30

As title, what is different betweem

stm32f10x-standard-library&

#

library.

Shall we makeSTM32CubeMX to usestandard peripheral library?

If possible, please let me know how to do detail.

Also, what is different of

stm32cubemx &

stm32cubef1 ‌?

BR

LC

<LINK NO LONGER ACTIVE>

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef1.html

7 REPLIES 7
john doe
Lead
Posted on April 29, 2017 at 17:45

STM32CubeMX is an application.  It gives you  GUI for choosing your pinouts, pin functions, and clock timings, among other things. It generates initialization code for the peripherals you choose. It doesn't write your program for you, it just initializes the peripherals.

stm32cube_f1_xx is the HAL library for the stm32f1 series. it is example code and drivers, too.

standard peripheral library is deprecated. HAL is the library/set of libraries currently maintained and promoted by the factory.

L C
Associate II
Posted on April 30, 2017 at 00:48

Dear ALL

I want to use SPI function. Just to push a data(8-bit) out via SPI port.

To compare this function in 

standard peripheral library & HAL library, the HAL library's seem very complex.

idea 1.

To push a command(for ili9341) or data to function '

HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)

' one by one.

This function is powerful and check many thing. However it has higher overhead & less efficiency.

If use it for a lot data transfer will better.

idea 2.

Generally ILI9341's data is one command with one or more parameter/data. 

Store them into array and pass to HAL_SPI_Transmit() is possible.

For example:

array[0] = 0x04   //total number of array

array[1] = 0xCF   //ILI9341 command

array[2] = 0x30   //parameter

array[3] = 0x00   //parameter

How to separately handle the command and parameter for D/C pin operation? 

1) If simply pass the array to HAL_SPI_Transmit(), I afraid it handle the whole array like parameter only.

2) How to handle the rest parameter, if special handle the command first? It is because the parameter is start from the third location(not first location).

Please share your comment to me.

BR

LC

Posted on April 30, 2017 at 00:43

Thanks John Doe 

Posted on April 30, 2017 at 05:57

I wrote a series of articles about SPI recently, here is the last piece that deals with calling the HAL routines to get the transfer done:

http://embedded.fm/blog/2017/4/26/i-apply-spi-good-vibrations

 

It's not really clear what your concerns are. You say that the HAL routines are very complex, and yet the only complication in SPI is that ST doesn't handle the chip select line very well and you have to call two GPIO functions.

If you are worried that the routines are doing too much on your behalf, remember that these processors are running at many megahertz and your compiler is optimizing the hell out of the code and probably NOT having the processor do as much as you think it is. You could paste values into the device registers directly, but you probably have better things to do with your time than second guess the compiler by simulating assembly code.

Andrei from The Great White North.

S.Ma
Principal
Posted on April 30, 2017 at 15:03

Start with a hal example close to your needs. Once functional, if performance beyond compiler's ability is mandatory, convert to the LL (Low Layer macrod) in a later step.

Posted on May 01, 2017 at 04:12

Andrei Thanks for your comment.

It is because my english is not good, so my explanation is not clear.

Let me try again.

'the HAL routines are very complex' I mean that there will process & check many thing in this function such time out.

In some design(small system), never check it.

The max. freq. of STM32F1xx is 72MHz and is very faster than many chip. However in design point of view, we should optimize it more.

With HAL library, it is powerful & safe.

If using simple method like assembler language, direct write a value to registers. It will be faster.

It is trade off between high level & low level language. right?

LC

L C
Associate II
Posted on May 01, 2017 at 04:14

Thanks & note.

I shall try it step by step.

LC