[STM] Getting started with IAR for ARM. IDE quick setup.

Hardware issues, electronic components, schemas, Arduino, STM32, Robots, Sensors
Post Reply
Administrator
Site Admin
Posts: 81
Joined: 26-Feb-2014, 17:54

[STM] Getting started with IAR for ARM. IDE quick setup.

Post by Administrator » 06-Oct-2014, 19:45

Hello.

First of all you should download installation package for: "IAR Embedded Workbench for ARM" at http://www.iar.com/Service-Center/Downloads/
(size-limited evaluation license)

When the installation is complete you need to register online (you can use any name and country, but you need valid e-mail). You will get a registration key by e-mail.

Now you can activate the product with the key and run the main window:
IAR0.png
IAR0.png (100.32 KiB) Viewed 30960 times
Click the menu item "Create New Project", select the language and MCU architecture (ARM, C/C ++ language) in the dialog window:
IAR1.png
IAR1.png (19.63 KiB) Viewed 30960 times
You will get a new project that contains empty main.c file.

Next step is to configure the project properties for your MCU (board) STM32F3Discovery (stm32f303xx). To do this, click the "Device" button and choose the correct device for you project from the list (click button with "+" sign).
IAR2.png
IAR2.png (32.96 KiB) Viewed 30960 times
It is recommended to include the library named: "Cortex® Microcontroller Software Interface Standard (CMSIS)". Most likely it is already installed in the IDE and is available in default "Include-paths".
IAR3.png
IAR3.png (37.7 KiB) Viewed 30960 times
For project configuration, you will need to configure include-paths to MCU and SPL header files. Whether your project uses the Standard Peripheral Library (SPL) then you should add this "#define": USE_STDPERIPH_DRIVER
IAR4.png
IAR4.png (39.9 KiB) Viewed 30960 times
The CMSIS and SPL libraries provide some abstracted functions for MCU setup, input/output, system startup code, and peripheral setup functions.
On the Debugger option page, make appropriate settings for the debugger you are using (ST-LINK):
IAR5.png
IAR5.png (32.93 KiB) Viewed 30959 times
On the Debugger->Download page, select the "Flash Loader" option:
IAR6.png
IAR6.png (36.51 KiB) Viewed 30959 times
When your board is connected to the PC via USB-cable select SWD option. When you use a device programmer then select JTAG option:
IAR7.png
IAR7.png (31.56 KiB) Viewed 30959 times
Do not forget to add tool-chain files to your project. These files are required to build a project in the IAR tool-chain and are part of CMSIS and SPL.

startup_stm32f303xc.s - assembler file from tool-chain, that creates the C runtime environment (stack and heap), initialises the processor, defines and setups interrupt vector table, and jumps to main().

system_stm32f30x.c - here you will find the CMSIS SystemInit() routine and other customised code for your board that configures crystal frequency (HSI/HSE) at 72 MHz, PLL setup, SRAM configuration etc.
DONE!

Administrator
Site Admin
Posts: 81
Joined: 26-Feb-2014, 17:54

Re: [STM] Getting started with IAR for ARM. IDE quick setup.

Post by Administrator » 13-Apr-2015, 13:57

Всем привет.

Качаем "IAR Embedded Workbench for ARM" (size-limited evaluation license) http://www.iar.com/Service-Center/Downloads/

Устанавливаем и регистрируемся на сайте (можно под любым именем/страной, главное e-mail) и получаем код регистрации по e-mail.

Активируем продукт и запускается главное окно:
Image

Жмём в меню "Create New Project", а далее в окне выбираем язык и архитектуру (ARM, C/C++ language):
Image

Появится новый проект, в котором будет файл main.c
Необходимо настроить проект под наш микрокотроллер - STM32F3Discovery (stm32f303xx). Для этого выбираем кнопку "Device" и с помощью кнопочки списка ищем нашу модель.
Image

Следующим шагом рекомендуется включить библиотеку "Cortex® Microcontroller Software Interface Standard (CMSIS)" Скорее всего она уже установлена в IDE и прописана в стандартных путях Include.
Image

Продолжаем тему Include-ов и прописываем пути к заголовочным файлам нашего микроконтроллера и к библиотеке "Standard Peripherals Library". Если в проекте будет использоваться эта библиотека, то настоятельно рекомендуется прописать "#define": USE_STDPERIPH_DRIVER
Image

Осталось настроить отладчик ST-LINK:
Image

Ставим галочку "Flash Loader", чтобы программка прошивалась:
Image

Если у нас микроконтроллер подключен через USB-шнурок - то выставляем SWD, а если всё по-взрослому через программатор, то ставим JTAG:
Image
В проект следует включить 2 файла из библиотеки STD Peripherals Library:
startup_stm32f303xc.s - модуль, написанный на ASMe, по сути загрузчик, который инициализирует контроллер, настраивает таблицу прерываний и передаёт управление в main();
system_stm32f30x.c - здесь SystemInit(), настройка (HSI/HSE) Clock на 72 MHz и PLL (необходим в проекте).
ГОТОВО!

Post Reply