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?
Solved! Go to Solution.
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
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