Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:15:43+00:00 2026-05-14T23:15:43+00:00

Lately, I’ve been cleaning up some some C code that runs on an ARM7

  • 0

Lately, I’ve been cleaning up some some C code that runs on an ARM7 controller. In some situations (upgrade, fatal error, etc…) the program will perform a reset. Presently it just jumps to 0 and assumes that the start-up code will reinitialize everything correctly. It got me to thinking about what would be the best procedure a la “Leave No Trace” for an ARM reset. Here is my first crack at it:

void Reset(void)
{
   /* Disable interrupts */
   __disable_interrupts();

/* Reset peripherals, externals and processor */
AT91C_BASE_RSTC->RSTC_RCR = AT91C_RSTC_KEY | AT91C_RSTC_PERRST | AT91C_RSTC_EXTRST| AT91C_RSTC_PROCRST;

while(AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_SRCMP);

/* Jump to the reset vector */
(*(void(*)())0)();
}

This code assumes the IAR ARM compiler and the At91Lib. Anything I haven’t considered?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:15:43+00:00Added an answer on May 14, 2026 at 11:15 pm

    That should do the trick. I use a similar function with an Atmel SAM3U. I never bothered to poll the status register, but that’s a good idea and I’m going to go add that right now!

    However, you should never get to the reset vector line since the processor will have already reset. IAR has an __noreturn attribute for use in these cases to allow further compiler optimization. I also load my reset function into ram (see __ramfunc) since I use at the end of firmware updates where the microcontroller can’t run from flash.

    Also, you shouldn’t need AT91C_RSTC_EXTRST flag unless you are controlling the reset of external devices with that line.

    __noreturn void Reset(void)
    {
        __disable_interrupts();
    
        AT91C_BASE_RSTC->RSTC_RCR = AT91C_RSTC_KEY |
                                    AT91C_RSTC_PERRST |
                                    AT91C_RSTC_EXTRST |
                                    AT91C_RSTC_PROCRST;
    
        while (AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_SRCMP);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lately I had to change some code on older systems where not all of
Lately I've been in the habit of assigning integer values to constants and simply
Lately I've been using XPathDocument and XNavigator to parse an XML file for a
Lately I've been taking a look at Haxe , to build an application to
Lately, I've been going through a pretty weird phase. I feel the need to
Background Lately I've become a fanatic that everything I type while working on a
Lately I've be moving source files around in our source tree. For example placing
Lately I have seen a lot of blog posts concerning how to build loosely
Lately all modern programming languages have a definitive web site to support, distribute, learn
Lately I've found myself constantly running ILDASM to study the MSIL output of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.