setting up a register

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

setting up a register

ソリューションへジャンプ
1,570件の閲覧回数
pmrlcbtcphtzjdq
Contributor III
スポイラ
 



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 件の賞賛
返信
1 解決策
1,558件の閲覧回数
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 件の賞賛
返信
1 返信
1,559件の閲覧回数
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 件の賞賛
返信