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
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:
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:
So we have:
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 >
- Preprocessor > Defined symbols > (optional)
- 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
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.
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.