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

  • Home
  • SEARCH
  • 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 6857061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:58:03+00:00 2026-05-27T01:58:03+00:00

I am having a very hard time figuring out how to solve the following

  • 0

I am having a very hard time figuring out how to solve the following problem. I am on an embedded system with very little memory and want to minimize memory usage.
Pointers have always confused the heck out of me and will always do.

I have a whole bunch of defines for register addresses:

#define GPIO_PORTA_BASE      (*((volatile unsigned long *)0x40004000))
#define GPIO_PORTB_BASE      (*((volatile unsigned long *)0x40005000))
//etc..

These registers are direct accessible. e.g:

GPIO_PORT_BASE &= 0x01;

What I need is an array that contains the above registers so that I can easily map them to an index. e.g:

not_sure_what_to_declare_the array_as port_base_array[] {
   GPIO_PORTA_BASE,
   GPIO_PORTB_BASE,
   //etc
}

What I need to end up being able to do is something like this:

volatile unsigned long *reg;
*reg_a = port_base_array[0];
reg_a &=0x1;

I am using gcc to compile my code for arm cortex m3.

Any insight would be appreciated.

  • 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-27T01:58:04+00:00Added an answer on May 27, 2026 at 1:58 am

    I don’t know why @Etienne deleted his answer, but it contained the essential information: The address is cast to volatile unsigned long *. That’s what you need an array of.

    typedef volatile unsigned long* reg_addr;
    
    reg_addr registers[] = {
      &GPIO_PORTA_BASE,
      &GPIO_PORTB_BASE,
      // ...
    };
    

    We need to take the address again (&GPIO_PORTA_BASE), since the macro automatically dereferences them. Access as:

    *registers[i] &= your_value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably very easy, but I'm having a hard time figuring it out.
I'm having a hard time figuring this problem out - I am trying to
Ok, I have been having a VERY hard time figuring this out. I guess
I'm having a very hard time wrapping my head around this problem (it might
I'm having a hard time figuring out how to do this if statement. I
I'm having a hard time figuring out how to implement a factory pattern in
I am having a very hard time finding a standard pattern / best practice
I've been having a very hard time finding good examples of UIScrollView. Even Apple's
i am very new to Adobe Air and i am having a hard time
I'm having a very hard time getting the 2 buttons in the 2nd child

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.