{"id":10038,"date":"2015-12-07T20:52:50","date_gmt":"2015-12-08T01:52:50","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=10038"},"modified":"2023-04-20T23:08:12","modified_gmt":"2023-04-21T03:08:12","slug":"integrating-stm32f4xx-standard-peripheral-library-mikroc-pro-arm","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/integrating-stm32f4xx-standard-peripheral-library-mikroc-pro-arm\/","title":{"rendered":"Integrating STM32F4xx Standard Peripheral Library with MikroC Pro for ARM"},"content":{"rendered":"<p>STM32F4xx series micros are far more advanced than anything else similar in the market. Apart from being fast 32-bit MCUs, STM32F4s have rich hardware peripheral support with DSP engine bonus. In terms of capabilities versus price tag, STM32F4s are all-square-winners. In recent times there\u2019s a surge in the STM32 user community. STM32 Discovery boards are proliferating like never before. In several occasions recently, I received tangible amounts of queries from readers regarding integration of STM32F4xx Standard Peripheral Library (SPL) with MikroC Pro for ARM and so even though it is not one of my mainstream posts on STM32 ARMs, I felt that I should address this topic. Previously I showed <a href=\"http:\/\/embedded-lab.com\/blog\/?p=8869\" target=\"_blank\" rel=\"noopener noreferrer\">how to port STM32F1xx SPL for STM32F1xx series devices with MikroC<\/a>. This post will not be different from the former one \u2013 only minute changes. I suggest readers to read the <a href=\"http:\/\/embedded-lab.com\/blog\/?p=8869\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>earlier post<\/strong><\/a> first before reading this one.\u00a0<a href=\"http:\/\/embedded-lab.com\/blog\/integrating-stm32f4xx-standard-peripheral-library-mikroc-pro-arm\/stm32f4-discovery-board\/\" rel=\"attachment wp-att-10040\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10040\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/STM32F4-Discovery-Board.jpg\" alt=\"STM32F4 Discovery Board\" width=\"500\" height=\"318\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>At present MikroC compiler is one of the few compilers that hasn\u2019t yet officially provided any support for SPL integration. Hopefully they will add this support in the future but the way MikroC addresses a solution is different from other compilers. MikroC has a really awesome IDE and a rich library base support while SPL gives its user more control over on a chip\u2019s hardware. Like I said before together these become a doubled-edge sword.<\/p>\n<h4>Tools Needed<\/h4>\n<p><span style=\"font-size: 0.95em;line-height: 1.6em\">Firstly you\u2019ll need MikroC Pro for ARM. The compiler has a demo version that provides an 8k code limit, enough for first-hand ARM experience. You\u2019ll need a STM32F4xx board. I used a STM32F407VG Discovery. This board from <a href=\"https:\/\/www.st.com\" target=\"_blank\" rel=\"noopener noreferrer\">ST Microelectronics<\/a><\/span><span style=\"font-size: 0.95em;line-height: 1.6em\">\u00a0is somewhat the flagship Discovery board of the STM32F4 series and it is very popular. Finally you\u2019ll need STM32F4xxx SPL which I included in my example. The files in them are modified to work with MikroC environment.\u00a0<\/span><\/p>\n<h4>Things to do<\/h4>\n<p>Firstly we need to prepare our MikroC PRO for ARM compiler for linking the SPL. I\u2019m assuming that the compiler is preinstalled. First go to the compiler\u2019s installation folder and locate the <i>include<\/i> folder. In my case, it is: <i><span style=\"text-decoration: underline\">C:\\Users\\Public\\Documents\\Mikroelektronika\\mikroC PRO for ARM\\Include<\/span><\/i>.<\/p>\n<p>In this folder, there\u2019s a file named <i>stdint.h.<\/i> Rename it to <i>stdint (backup).h <\/i>and copy the new <i>stdint.h <\/i>file from the supplied folder to this location. If you already did so during my previous post or upgraded to MikroC Pro for ARM version 4.15 (the latest release at the time of this writing), then skip this part.<\/p>\n<p><a href=\"http:\/\/embedded-lab.com\/blog\/porting-st-standard-peripheral-library-with-mikroc-for-arm\/stdint-modification\/\" rel=\"attachment wp-att-8870\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8870\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2014\/07\/stdint-modification.png\" alt=\"stdint modification\" width=\"601\" height=\"382\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2014\/07\/stdint-modification.png 601w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2014\/07\/stdint-modification-550x349.png 550w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/a><\/p>\n<p>Next we have to change some options of the compiler. Launch the compiler and the follow as shown below:<b><br \/>\nTools \u00a0 \u00a0&gt;&gt; \u00a0 \u00a0Options \u00a0 \u00a0&gt;&gt; \u00a0 \u00a0Output Settings<\/b><\/p>\n<p><span style=\"font-size: 0.95em;line-height: 1.6em\">Check <\/span><i style=\"font-size: 0.95em;line-height: 1.6em\">Case sensitive<\/i><span style=\"font-size: 0.95em;line-height: 1.6em\">. Apply and close this window. Again skip this part if you already did so earlier.<\/span><\/p>\n<p><a href=\"http:\/\/embedded-lab.com\/blog\/porting-st-standard-peripheral-library-with-mikroc-for-arm\/compiler-changes\/\" rel=\"attachment wp-att-8876\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8876\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2014\/07\/compiler-changes.png\" alt=\"compiler changes\" width=\"601\" height=\"403\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2014\/07\/compiler-changes.png 601w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2014\/07\/compiler-changes-550x368.png 550w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/a><\/p>\n<p>Be cautious from now on with regards to naming and letter cases because the compiler is now sensitive to this or otherwise you\u2019ll be doomed in the abyss of programming misfortune. Just a simple but useful tip &#8211; Compile your code few often after some edits or modifications. This will greatly help you to debug tiny mistakes in a small frame of coding window.<\/p>\n<p>Finally keep the SPL in secured location. Whenever you code a new project with the SPL, copy it from this location and use it with the project. This will make sure that the original SPL copy is not accidentally modified.<\/p>\n<h4>Coding with SPL<\/h4>\n<p>The example code is just another blinking code example as it will suffice. \u00a0I\u2019m not going to tell you how to create a new project in MikroC. I presume it is known to you. Create a new project and using the <b><i>Project Manager <\/i><\/b>add all the source and header files from the SPL folder. You can simply add the header and source files of only the required peripherals or you can add all if you are not sure which one stand for which. The former approach takes less compilation time than the latter. Additionally add the <b><i>defines.pld<\/i><\/b> Project Level Definition file. Now you are ready to code with the SPL.\u00a0<a href=\"http:\/\/embedded-lab.com\/blog\/integrating-stm32f4xx-standard-peripheral-library-mikroc-pro-arm\/ide-2\/\" rel=\"attachment wp-att-10039\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10039\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/IDE.png\" alt=\"IDE\" width=\"590\" height=\"298\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/IDE.png 590w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/IDE-550x277.png 550w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p>Please be noted that since the SPL is not yet officially integrated by MikroElektronika, you\u2019ll notice red error markers under various parts of a code with SPL. This is not unusual and not an error. \u00a0So no worries.<\/p>\n<h6><em>Code:<\/em><\/h6>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>#include \"stm32f4xx_gpio.h\"<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>#include \"stm32f4xx_usart.h\"<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>#include \"stm32f4xx_rcc.h\"<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>void setup_GPIOs();<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>void check_LEDs();<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>void main() <\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>{<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 unsigned char s = 0;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 <\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 setup_GPIOs();<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 check_LEDs();<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 <\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 while(1)<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0))<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 while(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == 1);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 s++;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(s &gt;= 6)<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 s = 0;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 switch(s)<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case 1:<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_12);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case 2:<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_13);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case 3:<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_14);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case 4:<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_15);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 case 5:<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_12);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_13);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_14);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, GPIO_Pin_15);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 default:<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Delay_ms(90);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_ResetBits(GPIOD, GPIO_Pin_12);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_ResetBits(GPIOD, GPIO_Pin_13);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_ResetBits(GPIOD, GPIO_Pin_14);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GPIO_ResetBits(GPIOD, GPIO_Pin_15);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Delay_ms(90);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0\u00a0 }<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>}<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>void setup_GPIOs()<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>{<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitTypeDef GPIO_InitStructure;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_Init(GPIOA, &amp;GPIO_InitStructure);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0 GPIO_Init(GPIOD, &amp;GPIO_InitStructure);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>}<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>void check_LEDs()<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>{<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0 GPIO_SetBits(GPIOD, (GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15));<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0 Delay_ms(900);<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>\u00a0\u00a0\u00a0 GPIO_ResetBits(GPIOD, (GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15));<\/i><\/span><\/pre>\n<pre><span style=\"color: #0000ff\" data-darkreader-inline-color=\"\"><i>}\n<\/i><\/span><\/pre>\n<p><a href=\"http:\/\/embedded-lab.com\/blog\/integrating-stm32f4xx-standard-peripheral-library-mikroc-pro-arm\/20150207_224408\/\" rel=\"attachment wp-att-10041\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10041\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/20150207_224408.jpg\" alt=\"20150207_224408\" width=\"590\" height=\"368\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/20150207_224408.jpg 590w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/20150207_224408-550x343.jpg 550w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a> <a href=\"http:\/\/embedded-lab.com\/blog\/integrating-stm32f4xx-standard-peripheral-library-mikroc-pro-arm\/20150207_224410\/\" rel=\"attachment wp-att-10042\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10042\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/20150207_224410.jpg\" alt=\"20150207_224410\" width=\"590\" height=\"365\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/20150207_224410.jpg 590w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2015\/02\/20150207_224410-550x340.jpg 550w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><br \/>\nDemo video link: <a href=\"https:\/\/www.youtube.com\/watch?v=ngk-4Lm11yU\">https:\/\/www.youtube.com\/watch?v=ngk-4Lm11yU<\/a>.<\/p>\n<p><span style=\"font-size: 0.95em;line-height: 1.6em\"> Personally I haven\u2019t made myself dependent on SPL so far and I believe in raw level coding-learning. SPL allows textbook entry in STM32 arena. No wonder it makes coding easy but the adverse effect of it in my eyes is the fact that its users will spend less time with reference manuals and datasheet. This in turn will affect them in acquiring solid learning of internal hardware peripherals and their working principles. If SPL is to make life easy this way then why not use MikroC libraries. Those are even more easy to use. Sometimes libraries are lifesavers while sometimes they are curse. Sometimes you would not like to reinvent the \u201cwheel\u201d but you would certainly like to make a vehicle with it and that my friend worth more than anything else. At this point I don\u2019t want to debate further in this matter. I leave this choice to users.<\/span><\/p>\n<p>Happy coding.<\/p>\n<p>Repository: <a href=\"https:\/\/github.com\/sshahryiar\/STM32-Tutorials\">https:\/\/github.com\/sshahryiar\/STM32-Tutorials<\/a><\/p>\n<p><i>Author: Shawon M. Shahryiar<br \/>\n<\/i><\/p>\n<p><a href=\"https:\/\/www.youtube.com\/c\/sshahryiar\">https:\/\/www.youtube.com\/c\/sshahryiar<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/sshahryiar\">https:\/\/github.com\/sshahryiar<\/a><\/p>\n<p><a href=\"mailto:sshahryiar@gmail.com\"><i>sshahryiar@gmail.com<\/i><\/a><i><\/i><i>\u00a0 \u00a0 \u00a0 \u00a0 <\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>STM32F4xx series micros are far more advanced than anything else similar in the market. Apart from being fast 32-bit MCUs, STM32F4s have rich hardware peripheral support with DSP engine bonus. In terms of capabilities versus price tag, STM32F4s are all-square-winners. In recent times there\u2019s a surge in the STM32 user community. STM32 Discovery boards are proliferating like never before. In several occasions recently, I received tangible amounts of queries from readers regarding integration of STM32F4xx Standard Peripheral Library (SPL) with MikroC Pro for ARM and so even though it is not one of my mainstream posts on STM32 ARMs, I<\/p>\n","protected":false},"author":5,"featured_media":10039,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[733,1474,1466],"tags":[799,803,804,1114,1113,850],"class_list":["post-10038","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stm32","category-stm32-tutorials","category-tutorials","tag-advanced-embedded-systems","tag-arm-microcontrollers","tag-mikroc-pro-for-arm","tag-st-standard-peripheral-library","tag-stm32f407vg-discovery","tag-stmicroelectronics"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/10038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=10038"}],"version-history":[{"count":12,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/10038\/revisions"}],"predecessor-version":[{"id":15162,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/10038\/revisions\/15162"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/10039"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=10038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=10038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=10038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}