This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x CAN transmit address transmit question

Hi,
I an using the CAN system in the AM335x ICE V2.1 board. I have it working,
transmitting and receiving but am having trouble using the CAN message RAM. I have
a question in on the receive but now I am having trouble in the TRANSMIT part.

I use the CANMsgObjectConfig(unsigned int baseAdd, can_frame* canPtr) from the dcan_frame.c
utilities from dcanTxRx starterware routine. This configures a slot in the Message RAM
with the data contained in the can_frame object. This includes the dlc, length of the packet
and the CAN id value.

I wanted to use these slots for transmit so all I would have to do would be copy the
data into the slot and set the flags to send the data. Like this, I have an internal structure
that holds the data on all the CAN message RAM slots (frames) plus some other information

/*******************************
Send a CAN packet

@param data Data buffer
@param len Length of data <= 8
@param slot Slot #

@return 0 if successful, <> 0 if not
******************************/

int CANTransmit( unsigned char *data,int len,int slot)
{
int rtnval = 0;
unsigned int msgNum = frames[slot].msgNum;
unsigned int *ptr = (unsigned int *)data;
can_frame *frame = (can_frame *)&frames[slot].frame;

frame->data = (unsigned int *)data;

/* Set the message valid bit */
DCANMsgObjValidate(DCOM_REGS, DCAN_IF1_REG);

/* Set the data length code */
DCANDataLengthCodeSet(DCOM_REGS, len, DCAN_IF1_REG);

/* Populate the data bytes in the data registers */
if( ptr != 0 )
DCANDataWrite(DCOM_REGS, ptr, DCAN_IF1_REG); <-- Just copy the data into the msg RAM

/* Configure the command register */
**** This enables the XMIT and away it goes.
**** msgNum is the CAN Message RAM location (gotten when we set it up using
CANMsgObjectConfig)
DCANCommandRegSet(DCOM_REGS, (DCAN_DAT_A_ACCESS | DCAN_MSG_WRITE | DCAN_TXRQST_ACCESS |
DCAN_DAT_B_ACCESS | DCAN_ACCESS_CTL_BITS |
DCAN_ACCESS_ARB_BITS), msgNum, DCAN_IF1_REG);

return rtnval;
}

This works the first time I use it then for all subsequent attempts it uses the address from last
transmitted data address and never resets.

How is the CAN message RAM supposed to work ?

Right as a stopgap I am calling CANMsgObjectConfig() instead of this routine and that
sends to the right address.

Any suggestions ?

--jim schimpf