cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find libraries???

alexou-girl99
Associate
Posted on November 23, 2016 at 16:48

Hi,

I am new with the ST microcontroller and I was looking for some basic libraries. I am using a STM32F373CC and I want to use the SPI, ADC and DAC on the microcontroller... I have used the STM32 cube software to generate a basic code who's initializing all the things I need to initialize to use the SPI and the ADC.

I just don't know where to start... I've tried to look just how to control an output (change the output for a high/low) and I havent found out how to do so yet...

I've been on the ST website and they have a section called : embedded software... but still, it doesnt look like its gonna be of any help to me.

http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f3-series/stm32f373/stm32f373cc.html

Thank you again for the help!

Alexia.

#stm32f373cc
3 REPLIES 3
slimen
Senior
Posted on November 23, 2016 at 17:55

Hello,

Welcome to the community.

I highly recommend to start with ''Getting started'' manuals which allow you to go step by step to install tools and start your project.

You can refer to your

http://www.st.com/resource/en/reference_manual/dm00041563.pdf

for more clarification about your product and configuration.

You should review the datasheet of used product to be able to identify the pins assignment (free/usable pins)

Regarding the way to start in order to develop your application, you have various choices:

You can review the examples available in the

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

package dedicated for the various STM32F3 boards. 

You may find many examples under STM32Cube_FW_F3_V1.6.0 and re-use sections available in the examples or get inspired from them.

I also recommend to use the

http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

tool which allow you to initialize peripherals that you need and generate your starting projects. For more detail about CubeMx, take a look to STM32cubeMx user Manual. 

Hope this helps you.

Regards

Alan Chambers
Associate II
Posted on November 24, 2016 at 10:52

Hi,

>> I am new with the ST microcontroller and I was looking for some basic libraries.

What other microcontrollers do you have experience of? I'm not sure there are any ''basic'' libraries. Even setting up a SPI master needs you to visit several ''peripherals'':

- RCC to enable the SPI instance and to enable one or more GPIO instances for the MISO, MOSI, and SCK pins

- GPIO to correctly configure each pin in the relevant alternate function (i.e. SPI)

- SPI to configure the actual SPI channel, including enabling the interrupt flags you care about

- NVIC to enable the interrupt source for the SPI instance

- You also need to write ISRs for any interrupts you handle and integrate those with your driver

- I might have missed something

It's a bit confusing at first, and a bit of of a pain, and can involve a lot of trawling through the Reference Manual and Programming Manual. I mainly use F4s, and these documents are *excellent* resources. Sadly, there is a disconnect between the API of any library and the names of register and fields in the documentation. Resolving this can involve a lot of trawling through header files and even the implementation of the library. I've never looked at the documentation for the libraries, preferring the source code.

The Cube UI is nice and will generate a working project for you with all the initialisation code you need. For my money, the generated code is poorly organised and somewhat impenetrable, and the underlying HAL library is horrible, but it is still worth stepping through it line by line.

I mainly use the Standard Peripheral Library, for which there are many useful examples online and in the installation. I prefer it partly because I'm used to it, but mainly because it is non-intrusive: it is very easy to completely encapsulate the initialisation and other code, so that your application uses only your own driver API. I haven't worked out how to do with the HAL code that the Cube produces yet. Using SPL means writing the initialisation code yourself, or copying an example.

The third option is to directly use the memory mapped register interface. Each peripheral is represented by a struct instance that is overlaid on a specific memory location. The members of the struct correspond to the registers. Using this approach has a nice low level bare metal appeal, but is certainly more error prone. The SPL is implemented in terms of these structures, and mostly likely the HAL is, too.

The fourth option is to write your own library. You would learn a very great deal by doing this, but I suspect it is massive overkill for your first project. :)

UnicycleBloke
shingadaddy
Senior
Posted on November 24, 2016 at 18:26

This tripped me up a little too when I first got to the ST line. But alan and forumstm32 say it well. Simplified:

1:

The LATEST incarnation of libraries are the HAL libraries. Named after HARDWARE ABSTRACTION LAYER

These are found in the many downloadable collections called loosly refered to as CUBE. STM32CubeF4 for the F4 for example.

The other CUBE member of the family is STM32CubeMX. Its a GUI that can generate initialization code for you, using

the HAL Cube Libraries.

2:

The older and still heavily relied on STANDARD PERIPHERAL LIBRARIES.

The HAL stuff is still having some growing pains. But it clearly is where ST wants you to head.