What is the difference between the speed at which the TC275 CPU accesses various types of variables

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
HUOYU
Level 3
Level 3
50 sign-ins First like received First solution authored

Hello! In my project, I used CAN communication (classic CAN). I defined some bit-fields for variables in the CAN communication protocol, as shown in the following code: 

/* MCU feedback message A
 * */
typedef struct AppMCUfb1_msg_Bits
{
    uint64 ModeState  :2;                    /**< \brief [1:0] Mode State                  */
    uint64 MotorENST  :1;                    /**< \brief [2:2] Motor Enable State bit      */
    uint64 reserved_3 :5;                    /**< \brief \internal Reserved                */
    uint64 actSpeed   :16;                   /**< \brief [23:8] Actual Speed               */
    uint64 actTorque  :16;                   /**< \brief [39:24] Actual Torque             */
    uint64 MotorIrms  :8;                    /**< \brief [39:24] Motor Irms                */
    uint64 DC_BusVolt :8;                    /**< \brief [55:48] TimeOut Set               */
    uint64 MCU_life   :8;                    /**< \brief [63:56] MCU life,0-255           */
} AppMCUfb_msgA_Bits;

As shown above, the classic CAN has 8 bytes of data. There are many more such messages in my project, about 100 different frames.

 

Use example:

mvu1.rxDataA.D.ModeState;

I managed frames from the same device with a global variable, such as "mcu1";
"rxDataA" indicates the frame A received from mcu1;
"D" means access data;
"ModeState" indicates the corresponding bit segment.

 

I wonder if a lot of bit-fields access slows down the CPU or increases CPU overhead? The speed at which the CPU accesses bits in the structure, compared with common variables, such as uint32.  What is the performance gap between the two speed?

I would be happy to listen to any suggestions you may have, thank you!

0 Likes
1 Solution
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @HUOYU 
The speed at which the CPU accesses bits in the structure, compared with common variables, such as uint32. What is the performance gap between the two speeds?
-- In my opinion, the difference in execution performance depends on how the compiler interprets the bit manipulation.
Before to jump a conclusion, It'd be better to check their assembly code.
BR,
Jeremy

View solution in original post

1 Reply
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @HUOYU 
The speed at which the CPU accesses bits in the structure, compared with common variables, such as uint32. What is the performance gap between the two speeds?
-- In my opinion, the difference in execution performance depends on how the compiler interprets the bit manipulation.
Before to jump a conclusion, It'd be better to check their assembly code.
BR,
Jeremy