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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:00:51+00:00 2026-06-04T12:00:51+00:00

Basicly I am getting data from another thread in the RTOS. This data is

  • 0

Basicly I am getting data from another thread in the RTOS. This data is a pin on the board. All the IO ports are in structures / unions in an iodefine.h file. See this for example on how Micrium made it:

struct st_portd {
union {
    unsigned char BYTE;
    struct {
        unsigned char B0:1;
        unsigned char B1:1;
        unsigned char B2:1;
        unsigned char B3:1;
        unsigned char B4:1;
        unsigned char B5:1;
        unsigned char B6:1;
        unsigned char B7:1;
    } BIT;
} DDR;
unsigned char wk0[31];
union {
    unsigned char BYTE;
    struct {
        unsigned char B0:1;
        unsigned char B1:1;
        unsigned char B2:1;
        unsigned char B3:1;
        unsigned char B4:1;
        unsigned char B5:1;
        unsigned char B6:1;
        unsigned char B7:1;
    } BIT;
} DR;
unsigned char wk1[31];
union {
    unsigned char BYTE;
    struct {
        unsigned char B0:1;
        unsigned char B1:1;
        unsigned char B2:1;
        unsigned char B3:1;
        unsigned char B4:1;
        unsigned char B5:1;
        unsigned char B6:1;
        unsigned char B7:1;
    } BIT;
} PORT;
unsigned char wk2[31];
union {
    unsigned char BYTE;
    struct {
        unsigned char B0:1;
        unsigned char B1:1;
        unsigned char B2:1;
        unsigned char B3:1;
        unsigned char B4:1;
        unsigned char B5:1;
        unsigned char B6:1;
        unsigned char B7:1;
    } BIT;
} ICR;
unsigned char wk3[95];
union {
    unsigned char BYTE;
    struct {
        unsigned char B0:1;
        unsigned char B1:1;
        unsigned char B2:1;
        unsigned char B3:1;
        unsigned char B4:1;
        unsigned char B5:1;
        unsigned char B6:1;
        unsigned char B7:1;
    } BIT;
} PCR;
};

Very clever way if you ask me.
So I save this pin as 2 chars in a struct, called Port and Pin.

struct StepperMotor {
  CPU_INT32U ID;
  CPU_CHAR *EnablePort;
  CPU_CHAR EnablePin;
  CPU_CHAR *DirectionPort;
  CPU_CHAR DirectionPin;
  CPU_CHAR *PulsePort;
  CPU_CHAR PulsePin;
};

I would like to use the pin in this way:

(struct st_portd)(steppermotor->PulsePort)->DR.BYTE ^= (1 << steppermotor->PulsePin);

steppermotor is the struct.
Only with this way I get an error saying

request for member ‘DR’ in something not a structure or union

How am I able to use the steppermotor->PulsePort->DR.BYTE without making a new variable for it?
I hope anyone can help me!

  • 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-06-04T12:00:53+00:00Added an answer on June 4, 2026 at 12:00 pm

    Since you are casting a pointer, you should be casting it to a pointer to a structure, rather than a structure itself, like this:

    ((struct st_portd*)steppermotor->PulsePort)->DR.BYTE ^= (1 << steppermotor->PulsePin);
    

    Also note that your parentheses are in a wrong place.

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

Sidebar

Related Questions

i am creating rss reader application with php.it is basicly getting rss url's from
I wondering is there an equivalent of this feature from play framework http://www.playframework.org/documentation/2.0/JavaAsync Basicly
What I'm trying to do is basicly what this photo shows. When I select
Hi basicly i am trying to use the svm from here . It is
Ok, so I basicly have this list. What I'm trying to do is just
maybe its late or something, but this is freaking me out. Basicly im writing
Basicly this is what I have: Server:: Server (int port) { cout << Initializing
alt text http://produits-lemieux.com/database.jpg This is basicly my database structure one product (let say soap)
I'm trying to make a calculator which is basicly like this: user enters about
Having trouble converting the following code from dealing with IDs to Classes. Basicly what

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.