Pages

Sunday, December 25, 2016

In the blink of an ... LED

I strongly desired to enter 32bit arm microcontroller world with Atmels' SAM-D21 (Cortex-M0+) microcontroller, but the Arduino Zero board came very late and expensive... then Atmel was acquired and... And STM32 it was! In form of the Nucleo board which I see it much over Arduino Zero in terms of features, and four times cheaper!





So, I started to program it, learning more with every successful little project. I have a functional installation of OpenSTM32 IDE (which is an Eclipse plug-in which come also with an arm development toolchain), STM32CubeMX and st-link linux software. Also, I'm using HAL library (STM32CubeL1 package for my Nucleo model) instead of CMSIS library. I know CMSIS is a general library which covers all the different brands out there but I don't plan to use anything else apart of STM32 (my brain is already under pressure) so HAL it is - for now.

How I work with the IDE? Well, you can use OpenSTM32 stand-alone, without any problem, but you need a little more knowledge regarding the content of the libraries than a newbie has, more digging inside the forums, trying hard not to bother the more knowledgeable members. But STM32CubeMX helps you to configure the pins of the microcontroller in a visual manner and with protection against errors, in the end exporting the project to OpenSTM32 format. Project from which I take only a few files, replacing the counterparts from the OpenSTM32 project.



In short, I create the main project with OpenSTM32 for my board, I do the same in STM32CubeMX and make the required pins configuration, I take the generated .c and .h files from "src" and "inc" subfolders and replace the originals with them. Then I start writing the application with confidence that having the right configuration, I won't brick the board. I know is a lot of work, but I don't mind. Not yet.

I created three "Hello World!" testing applications and uploaded them in my github account:

1. OW01_Blink_LED_blocking_delay - it blinks the user LED from the board at three different speeds using a blocking delay. The user button from the board is used to change which delay will be used - it has an external interrupt assigned to it. It is just a part of the code from the application demo the board came with it, nothing more.

2. OW02_Blink_LED_non_blocking_delay - it blinks the user LED at three different speeds using non blocking delays (this time it is my contribution). It has the same functionality as the previous example and the user button is used in the same way.

3. Nucleo_blink_led - it blinks the LED using blocking delays. This one is very simple, it uses the Wiring language and is created online at mbed.org.

All three applications work as intended and should compile out of the box on a correctly installed IDE + toolchain. Also, install the Subversive Eclipse plugin to import the projects inside the IDE directly from the github repository.

No comments:

Post a Comment