setting up a register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

setting up a register

Jump to solution
682 Views
pmrlcbtcphtzjdq
Contributor III
Spoiler
 



I'm having a problem with a very simple thing - I don't know how to set up a register.

I need to set CAN_CTRL2[EACEN] - in CAN control register to 1.

The MPC5748g.h defines this register as follows:

 

 

#define CAN_CTRL2_EACEN(x)                       (((uint32_t)(((uint32_t)(x)) << CAN_CTRL2_EACEN_SHIFT)) & CAN_CTRL2_EACEN_MASK)

 

 

unfortunately, I don't understand how to use the (x) here...

 

The manual says that the register is at FFEC_0034h, so I figured out that the workaround could be:

 

 

    //set the CAN_CTRL2_EACEN to '1'
    uint32_t *reg_ptr;
    reg_ptr = 0xFFEC0034; //point to the register
    *reg_ptr = *reg_ptr | 0x1000; //set the 15th bit to '1'

 

 

 

Am I doing it correctly? Is there a better way to do it?

0 Kudos
1 Solution
671 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

it is just register mask definition. You can use

CAN_0->CTRL2 |= CAN_CTRL2_EACEN(1);

or

CAN_0->CTRL2 |= 0x10000;

to simply set EACEN bit.

BR, Petr

View solution in original post

0 Kudos
1 Reply
672 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

it is just register mask definition. You can use

CAN_0->CTRL2 |= CAN_CTRL2_EACEN(1);

or

CAN_0->CTRL2 |= 0x10000;

to simply set EACEN bit.

BR, Petr

0 Kudos