Tuesday 20 December 2016

First steps with stm32l152c-discovery. Environment.

I think that in the web there is a lack of materials about configuring and working with STM32L processors. So, the purpose of this post is to describe how to start working with STM32L152C-Discovery board. Particularly, I want to describe my workspace environment, required software and hardware components and the process of installation FreeRTOS on my device. Also, I want to check that all these things are working correctly.




Required software. 

 

First of all, we need a linux-based computer (host-computer) and a stm32l152c-discovery board (target device). The last one looks like this:

Additional components required for "printf" debugging are USB-RS-232 cable and Saleale Logic Analyzer. At the first time we don't need USB-RS-232 cable, we will use it later - linking our stm board and a computer console. Logic Analyzer is required for analyzing different protocols like RS-232, SPI, I2C.
On the host computer I will use:

  1. Debian Linux Operation system
  2. GCC cross-toolchain for cross-compiation
  3. Eclipse IDE for coding and
  4. GDB-debug for debugging
  5. OpenOCD for connection to the board through debugger
  6. FreeRTOS source code and additional libraries.

Environment.

We should install cross-compiler gcc, debugger and IDE:

aptitude install eclipse gcc-arm-none-eabi


and gdb:


aptitude install eclipse gdb-arm-none-eabi


I advise you to use the latest version of eclipse, that can be downloaded from eclipse.org. After downloading, unpack the archive to your preferred directory, for example:
tar -xzvf ./eclipse-cpp-neon-R-linux-gtk-x86_64.tar.gz -C ~/bin/


This will unpack the downloaded archive to the directory 'bin' in your home directory. During my work, I am going to use Eclipse 4.5 Mars (I will switch to another comfortable IDE in few weeks).
The next step, is to install openOCD for onboard debugging:

aptitude install openocd

After that, we need to install an Eclipse plugin.
Go to Help → Install New Software...
and find
C/C++GDB Hardware debugging
and install it.
And the last step is to download CubeMX utilities and unpack them.

Creating your first project.

Firstly, you should install CubeMX, it will allow you to work with you board without worrying about low-level routine. Go to CubeMX directory and execute installation binary. After this step, you will have a directory containing a distro of CubeMX. Go to this folder and execute STM32CubeMX file. In the program window, you should create 'New Project'. Then, you will see another window:

In that window you shoul choose you microcontroller or board (STM32L1-DISCO in my case). Double click on it, and you will see a configuration window for you microcontroller. It looks like this:
You can see, that a lot of pins are attached to lcd. We won't use onboard lcd, so we can easily change the pinout.
Also, we will use the FreeRTOS operation system. For this purpose, choose Configuration->MiddleWares->FreeRTOS->Enabled.
After configuration, I have the next scheme:

I have enabled a lot of different peripheral - uart, spi, i2c, ADC/DCA, GPIO . I will use it in the next few posts.
After selecting peripheral, save your project and choose the preferred working directory. Code for your board will be generated there.
When your scheme is ready, go to menu Project->Generate code to generate code for you board.

 


No comments:

Post a Comment