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 7652231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:42:54+00:00 2026-05-31T11:42:54+00:00

This is my code: volatile uint32_t value = *((volatile uint32_t *) 0xA0000000); // here

  • 0

This is my code:

volatile uint32_t value = *((volatile uint32_t *) 0xA0000000); // here `value` is 12498
value *= 2; // here `value` is still 12498
value |= 0x0000001; // still 12498

When analysing the variable value in my debugger, it holds the same value on all lines. What am I doing wrong?

  • 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-31T11:42:55+00:00Added an answer on May 31, 2026 at 11:42 am

    Maybe your debugger isn’t actually that good. When one of my tools doesn’t seem to behave, I always check it against another tool.

    Try to debug the old-fashioned way, with:

    volatile uint32_t value = *((volatile uint32_t *) 0xA0000000);
    printf ("A:%d\n", value);
    
    value *= 2;
    printf ("B:%d\n", value);
    
    value |= 0x0000001;
    printf ("C:%d\n", value);
    

    or some other output method if printf is unavailable (it looks like you may be working in the embedded space).

    See what you get with that – I’d be more inclined to trust printf-debugging than debuggers.


    If your problem is not with value but instead with the memory at location 0xA0000000, then it’s working as expected.

    You’re manipulating the local variable, not the memory location. You need to write the value back, with something like:

    *((volatile uint32_t *) 0xA0000000) = value;
    

    However, given your use of volatile, it’s entirely possible you just wanted a variable pointer to that location so that changes would reflect immediately.

    If that’s the case, you would need something along the lines of:

    volatile uint32_t *pValue = (volatile uint32_t *) 0xA0000000;
    *pValue *= 2;
    *pValue |= 0x00000001;
    

    In that case, the memory location would be changed at each instruction without having to explicitly write the value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this code snippet const volatile int * volatile * const X; but
Consider this C code: extern volatile int hardware_reg; void f(const void *src, size_t len)
I currently have this code: static void func( uint8_t var ); static volatile uint8_t
I have this cookie in Firefox: name:Vanilla-Volatile value:1-1313808454|54614728ee113ab09e4db5c863cd5cfa|1313635654|1|1313808454 domain:zhu13890.prod.xxxx.corp path:/ Then, I try to
The question came up when I saw this code: private static volatile ConcurrentHashMap<String, String>
Is there any reason to use volatile and synchronized together in this code? public
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
This code gives me an empty result. I expect it to print out the
This code attempts to dynamically switch the class of the StateContainer div from StateOne
This code snippet is from C# in Depth static bool AreReferencesEqual<T>(T first, T second)

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.