Electronics - IAR Systems - Setting up the IAR Embedded Workbench for the STM32L-DISCOVERY board

It's not essentially easy to set up the IAR Embedded Workbench for a new project.

All boards are different and all microcontrollers too.

In our case we will be using the STM32L152RBT6 one.

So, if you didn't use neither IAR nor the STM32L-DISCOVERY board, it would be a bit complicated to begin playing with your new toys.

Fortunately everything has a solution.

So, let's get started with this new tutorial!

Creating a new project and workspace

We have to create a new project.

In the menu bar > Project > Create New Project...

Then select the Toolchain  ARM and the Project template C with a main  and click OK

Save your project with a name, like project1.
 
Your project is now on your left, in the navigator.
 
Even if you saved your project, you didn't save your workspace yet.
For that, click the icon with several floppy disks (save all) or try to compile all by clicking > Project > Rebuild All.
A window ask you to save your workspace, give it a name and click OK.

The path until your project

Before continuing, you have to download the STM32L-DISCOVERY firmware package on the ST official website: http://www.st.com/web/en/catalog/tools/PF257908
 
In the tutorial we will need both Library and Utilities folders that you will find in this firmware package.
 
You are of course free to install it where you want, but it's a good idea to copy and paste it to your workspace in order to always have the default untouched firmware somewhere.
 
So let's suppose that you have installed your project1 there:
  • C:\dev\mcu\iar\arm\project1
Copy and paste the Libraries and Utilities folders at the same level that /arm.
 
Copy and paste the /src and /inc folders at the same level that /project1. They can be found there:
  • D:\soft\mcu\st\stm32l-discovery-firmware-1.0.2\Projects\AN3964-Temperature_sensor
So we have:
  • C:\dev\mcu\iar\arm\project1
  • C:\dev\mcu\iar\arm\src
  • C:\dev\mcu\iar\arm\inc
  • C:\dev\mcu\iar\Libraries
  • C:\dev\mcu\iar\Utilities

Come back to EWARM

Right click your project1 > Options... >
 
  • General Options >
    • Target > Processor variant > Select Device and choose > ST > STM32L152 > ST STM32L152xB
       
    • Library Configuration > Library > Full
    • Library Configuration > low-level interface implementation > Semihosted
    • Library Configuration > low-level interface implementation > stdout/stderr > Via semihosting
    • Library Configuration > CMSIS > Use CMSIS
       
    • Library Options > Printf formatter  > Full
    • Library Options > Scanf formatter  > Full
       
  • C/C++ Compiler >
    • Language 1 > Language > C
    • Language 1 > C dialect > C99 > C++ inline semantics
    • Language 1 > Language conformance > Standard with IAR extensions
       
    • Optimizations > Level > High > Size
       
    • Preprocessor > Additional include directories > 
           $PROJ_DIR$\..\
           $PROJ_DIR$\..\inc
           $PROJ_DIR$\..\..\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32L1xx
           $PROJ_DIR$\..\..\Libraries\STM32L1xx_StdPeriph_Driver\inc
           $PROJ_DIR$\..\..\Utilities\STM32L-DISCOVERY
    • Preprocessor > Defined symbols > (optional)
           USE_STDPERIPH_DRIVER
           STM32L1XX_MD
       
  • Linker >
    • List > Generate linker map file
  • Debugger >
    • Setup > Driver > ST-LINK
    • Download > Verify download
    • Download > Use flash loader(s)
  • ST-LINK >
    • ST-LINK > Reset > Connect during reset
    • ST-LINK > Interface > SWD
    • ST-LINK > Clock setup > CPU clock 32.0 MHz
    • ST-LINK > Clock setup > SWO clock > Auto
Click OK.
 
Download and Debug
 
Click the Download and Debug icon (with a green triangle in the toolbar), the COM LD1 led should come green and blink from red to green each time data is send to the board.

Conclusion

It wasn't so easy, but you succeeded to set up IAR Workbench with the STM32L-DISCOVERY board and its Cortext-M3 core.

Good job, you've made it. cool

 

Comments

Comment: 

Thank you for this helpful conclusion

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.