Inexpensive development boards are everywhere. They are a popular birthday gift nowadays and given away as door prizes just about every nerd gathering. What if you have one, but want to use it with your favorite IDE from MikroElektronika? Are you doomed, are you going to have to re-gift that shinny new development board your grandmother gave you? There is hope and here we will look at the how.
ST-LINK
The MikroE. mikroProg for STM32 follows the same standard that all ST products come with. The ST-LINK standard is an in-circuit debugger and programmer for their family of MCUs. It consists of a single wire interface to communicate with the application board or MCU. What this means for you is that all ST development boards run out of the box with MikroC.
For this demonstration we are going to use the STm32F042k6t6
STM32 Nucleo
One of the favorites because of pin compatibility with Arduino Nano but more important is that the board has an integrated bugger and programmer.
Programming with MikroC
Selecting the MCU is easy. All STM32 are supported, so just need to find the MCU on the Nucleo. That MCU is the STM32F042K6. I'm going to use the internal 48 MHz clock so the clock is set to that speed.
Next is to set up the clocks in the clock tree settings found under Project/Edit Project.
Enable the Internal 48 MHz clock.
Set the system clock to the Internal 48 Mhz clock
Hello World
Now that I have a project ready. Let's see if we can make it blink. I know from the following image that the LED is on PB3:
We need to set that pin to an output.
Add the following code:
sbit LED1 at GPIOB_ODR.B3; void main() { GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_3); while(1) { LED1 = ~LED1; Delay_ms(500); } }
Press the "Build and Program" button and watch the magic:
Within a few seconds you should see:
Summary
MikroElektronika ARM compilers have the advantage of being able to use the development board of your choice. So when Grandma gives you that perfect gift for your birthday, no need to fret that it isn't an MikroElektronika product, you can still use it with your favorite MikroE IDE.