Multi-MCU development

In embedded systems, the C/C++ source code is in some parts dependent to the MCU. It is difficult to reuse source code just as it is across multiple MCUs, but IAR Embedded Workbench has several features to support MCU migration and to increase portability.

IAR Embedded Workbench supports multi-MCU projects

A workspace in IAR Embedded Workbench can handle one, or many projects. Below you can see how each project for RH850, RL78, RX and SH are present in one workspace. Application source code can be shared by all projects.

Interrupt Control

A typical problem with code migration between different MCUs is how interrupt control such as enabling and disabling of interrupts are performed. Usually inline assembler is required to enable and disable interrupts. A few examples are shown below:

__asm(" CPSIE i"); // enable interrupt for ARM
__asm(" eint"); // enable interrupt for MSP430
__asm(" SETB EA"); // enable interrupt for 8051
__asm(" SETPSW I");// enable interrupt for RX
__asm(" EI "); // enable interrupt for V850

If you switch between different MCUs, your code has to be changed accordingly if using inline assembler.

An important feature in IAR Embedded Workbench that greatly enhances portability is compiler intrinsic functions that come as part of the compiler. There are two functions for controlling interrupts:__disable_interrupt and __enable_interrupt. The use of these two functions enables IAR Embedded Workbench to generate adequate instructions for each MCU.

To use intrinsic functions in your application, include the header file "intrinsics.h", and call intrinsic functions such as:

void foo( ) {


exe_func( ); 

__enable_interrupt(); }

Below a few examples (click to see larger images) using these intrinsics in different Renesas MCUs:





Char’s signedness

The signedness of the data type “char” may be different for each MCU/compiler as this is implementation-defined. It is important to have full control over how the implementation of plain char is handled in your compiler system, and that you have a consistent implementation across MCUs if you are developing using multiple MCUs which sometimes share source code. In the IAR Embedded Workbench you can change the signedness of “char” in the Project > Options dialog.



IAR Embedded Workbench is a powerful development environment for developing software for multiple MCUs. One workspace can handle multiple MCU projects, and intrinsic functions, e.g. for handling interrupts, and char signedness option are essential to increase the portability.

This article is written by Hiroki Akaboshi, Field Applications Engineer at IAR Systems Japan.

© IAR Systems 1995-2020 - All rights reserved.

We use cookies on this website to provide you with a better experience. You need to accept cookies to continue using this site. Cookies