This guide familiarizes you with IAR Embedded Workbench for Arm and how to get started with it using an NXP i.MX RT 1052 MCU board.
This is the first step in understanding how to develop complete programs with IAR Embedded Workbench for Arm. In this guide, you will explore the compiler, linker and debugger setup through the following steps:
The instructions are written for V.8.20 of IAR Embedded Workbench for Arm but older versions of the toolchain will resemble the screenshots in this document. If you don’t have a license of the toolchain already, you can register for an evaluation version. When everything is installed and ready, it is time to start the fun!
Generate a project
Now it’s time to see what your application will do!
To set the correct options for the compiler and linker, right-click the project in the Workspace window and choose Options. Now, go through the following:
Click OK to save all the changes we have made, build our project and see if you get any messages. The project should build successfully without errors or warnings.
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
7. Once you have located this line, place the following line just after it:
place at address mem:0x00002000 {section MyMainFunction};
8. Now, return to the project and do a Rebuild All. You will notice that in the map file, the location for the main( ) function has changed.
In an Arm Cortex-M architecture, the code has to be odd-byte aligned.
Download and debug
Some notices to start with:
You are now ready to download and debug your application!
Let’s work with some breakpoints.
printf("Hello world!\n");
static int loopCounter = 0;
while (1U)
{
loopCounter++;
}
return 0;
2. Set a breakpoint on loopCounter by right-clicking the line and choose Toggle Breakpoint (Code). Now, click Run and you quickly hit the breakpoint.
3. Click View->Breakpoints to see the Breakpoints window. Right-click the breakpoint you just created and choose Edit. In the Condition field, type:
loopCounter >= 10
4. Hit run – the breakpoint will only trip when the condition becomes true.
5. You can also use the Skip Count in the Edit window to make the breakpoint only trip after the line of code has been executed the number of times indicated in the Skip Count field.
7. In the Breakpoints window, delete the breakpoint you just set.
8. Right-click the same loopCounter line that you did in step 1 and choose Toggle Breakpoint (Log). In the Breakpoints window, right-click the log breakpoint you just created and click Edit. Check the box for “C-SPY macro message style” and put the following in the dialog box:
Note that it is a comma between the quotation mark and loopCounter, not a period.
9. Click OK.
10. At the bottom of the IDE, click the tab to open the Debug Log. Scroll to the bottom of the log window and then click Run; you will now see the value of loopCounter printed in the Debug Log window each time is passes through that section of code:
This gives you the power of doing printf( ) statements in your code without actually instrumenting your code with printf( ) statements so that when you go to Release mode, you don’t have to remove a bunch of statements from your project!