Part Number: MSP-EXP432E401Y
Tool/software: Code Composer Studio
Hi,
i'm using two MSP-EXP432E401Y with two BOOST-CC3135. The two LaunchPads are connected with CAN transceivers to the same bus. I want to send a CAN frame from one device to the other over the bus and then send it back via Wi-Fi. For that i'm using the network_terminal example.
For sending and receiving CAN i created two functions (see code below). I use the same code as in the CAN_singlemessage_receive/transmit examples, but with CAN1 instead of CAN0. The TCP-Server-device will call the CANRXConfig function at the beginning of the TCPServer-function. It will then configure the CAN and will repeatedly print "rxMsg" to the console (line 27) until a CAN message will arrive. The TCP-Client-device will call the CANTXConfig-function at the beginning of the TCPClient-function for sending the CAN frame.
What happens is that after typing the "recv" command with the TCP-Client-device, the TCP-Server-device stops printing "rxMsg" to the console. This could mean that a CAN message arrived, but then it should print a "1" to the console (line 30). Which it doesn't. And after sending the CAN frame the TCP-Client-device will only print the first 4 bytes of the frame sent although it is 8 bytes long (see Console picture). When i have a oscilloscpe available tomorrow i will try to measure the CAN message to make sure it is send.
Functions for sending and receiving the CAN frame:
void CANRXConfig(void)
{
/* Run from the PLL at 120 MHz */
sysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
configureCAN();
/* Initialize message object 1 to be able to receive CAN message ID 0x100 */
sCANRX.ui32MsgID = 0x100;
sCANRX.ui32MsgIDMask = 0;
/* Enable interrupt on RX */
sCANRX.ui32Flags = MSG_OBJ_RX_INT_ENABLE;
/* Size of message is 8 */
sCANRX.ui32MsgLen = sizeof(CANRX);
/* Load the message object into the CAN peripheral. Once loaded an
* interrupt will occur only when the CAN ID is 0x100. Use message
* object 1 for receiving messages */
MAP_CANMessageSet(CAN1_BASE, 1, &sCANRX, MSG_OBJ_TYPE_RX);
while(1)
{
UART_PRINT("%d\n\r", rxMsg);
if (rxMsg)
{
UART_PRINT("%d\n\r", rxMsg);
/* Re-use the same message object that was used earlier to configure
* the CAN */
sCANRX.pui8MsgData = (uint8_t *)&CANRX;
/* Read the message from the CAN */
MAP_CANMessageGet(CAN1_BASE, 1, &sCANRX, 0);
/* Check the error flag to see if errors occurred */
if (sCANRX.ui32Flags & MSG_OBJ_DATA_LOST)
{
UART_PRINT("\nCAN message loss detected\n");
}
else
{
UART_PRINT("CAN received: %u %u %u %u %u %u %u %u\n\r", CANRX[0],CANRX[1],CANRX[2],CANRX[3],CANRX[4],CANRX[5],CANRX[6],CANRX[7]);
}
rxMsg = false;
}
}
}
void CANTXConfig(void)
{
/* Run from the PLL at 120 MHz */
sysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
configureCAN();
/* Initialize message object 1 to be able to send CAN message 1 */
sCANTX.ui32MsgID = 0x100;
/* No mask needed for TX */
sCANTX.ui32MsgIDMask = 0;
/* Enable interrupt on TX */
sCANTX.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
/* Size of message is 8 */
sCANTX.ui32MsgLen = sizeof(CANTX);
/* Ptr to message content */
sCANTX.pui8MsgData = CANTX;
/* Send the CAN message using object number 1 */
MAP_CANMessageSet(CAN1_BASE, 1, &sCANTX, MSG_OBJ_TYPE_TX);
/* Check the error flag to see if errors occurred */
if(errFlag)
{
UART_PRINT(" error - cable connected?\n");
}
else
{
UART_PRINT("CAN sent: %u %u %u %u %u %u %u %u\n\r", CANTX[0],CANTX[1],CANTX[2],CANTX[3],CANTX[4],CANTX[5],CANTX[6],CANTX[7]);
}
while(1)
{
}
}
Regards
Christoph
