Hello, I am going a bit crazy here. I am initializing the CAN module on a TM4C123 eval board with the following statements:
// can data can.txdata = 0xAAAAAAAA; can.ptxdata = (uint8_t *) (&can.txdata);
msgobject.pui8MsgData = can.ptxdata; msgobject.ui32MsgID = 1365; msgobject.ui32MsgIDMask= 0; msgobject.ui32Flags = 0; msgobject.ui32MsgLen = 4; CANMessageSet(CAN0_BASE, 1, &msgobject, MSG_OBJ_TYPE_TX);
msgobject.pui8MsgData = can.ptxdata; msgobject.ui32MsgID = 10; msgobject.ui32MsgIDMask= 0; msgobject.ui32Flags = 0; msgobject.ui32MsgLen = 4; CANMessageSet(CAN0_BASE, 2, &msgobject, MSG_OBJ_TYPE_TX);
After initialized, I would like to update the data bytes of each message object and send as needed, for which I have created the following function, as explained on datasheet 17.3.5:
// ----------------------------------------------------------------------------- // can send // ----------------------------------------------------------------------------- void can_send(uint32_t ui32ObjID, uint32_t data){ can.txdata = data; // update DA and DB registers HWREG(CAN0_BASE + CAN_O_IF1CMSK) |= (CAN_IF1CMSK_WRNRD | CAN_IF1CMSK_DATAA | CAN_IF1CMSK_DATAB); // write to data bytes (same as _CANDataRegRead without arguments) can_write_data_reg(); // set a transmit request HWREG(CAN0_BASE + CAN_O_IF1MCTL) |= CAN_IF1MCTL_TXRQST; // initiate the transfer HWREG(CAN0_BASE + CAN_O_IF1CRQ) = ui32ObjID & CAN_IF1CRQ_MNUM_M; }
When I call this function, a packet is sent out but the ID does not correspond to the ID I configured in the message object. It is like it is ignoring the CAN_IF1CRQ_MNUM_M line.
Anybody have any idea what I am doing wrong here? Thanks!