element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog MSPM0 C++ project: service handler considerations
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 6 Sep 2026 3:21 PM Date Created
  • Views 40 views
  • Likes 4 likes
  • Comments 1 comment
  • gcc
  • MSPM0
  • easyL1105
  • c++
Related
Recommended

MSPM0 C++ project: service handler considerations

Jan Cumps
Jan Cumps
6 Sep 2026

You can use C++ for MSPM0 designs.
There's one watch-out: if you have your event handlers in a .cpp file, you have to wrap those functions in an extern "C" {} wrapper.

The SysConfig mechanism expect that the handlers have a particular name. But the C++ compiler will "mangle" function names in .cpp files. Surrounding the functions with the extern directive, tells the compiler to leave the function signature alone. 

In this example, I have a handler for a DMA interrupt. The SDK expects signature void DMA_IRQHandler (void).

If you don't wrap your handler, the linker will call the (predefined as weak) handler in the controller SDK's startup file. And that's a catchall handler (called Default_Handler) that 'll make the controller loop forever.
The linker will only have your handler called if its signature exactly matches the definition. Unmangled.
image

Because the default one in the SDK is flagged as weak, and your implementation not, the linker will ignore the SDK one and link in your function.

There are a few ways to wrap your handlers:

Surround the function

extern "C" {
void DMA_IRQHandler(void)
{
    /* Example interrupt code -- just used to break the WFI in this example */
    switch (DL_DMA_getPendingInterrupt(DMA)) {
        case DL_DMA_EVENT_IIDX_DMACH0:
            gChannel0InterruptTaken = true;
            break;
        default:
            break;
    }
}
}

Mark as external in with forward declaration

extern "C" {
    void DMA_IRQHandler(void);
}


// ...

int main(void)
{
    // ...
}

void DMA_IRQHandler(void)
{
    // ...
}

Both constructs have the same effect. 

There is no runtime cost. This is a build time mechanism to notify the toolchain. No code or data is added to your firmware.

  • Sign in to reply
  • shabaz
    shabaz 8 hours ago

    Super useful! This is also handy if writing or porting a library of code that might be marginally more convenient in C just for a bit more portability (since some microcontrollers might not offer C++ compiler), and then using that everywhere, including C++ programs.

    I think I've not written any C++ for MSPM0 yet, looking forward to doing that, since it's quite hard restricting to plain C, I always get the urge to write classes..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube