Other Parts Discussed in Thread: CONTROLSUITE
Hi,
i am using the M3 core for a while now with the CAN0 interface on GPIO_PB4 (CAN0RX) and 5 (CAN0TX). This works quite well so far.
Now i need a second CAN interface and simply want to use CAN1 on GPIO_PB0 (CAN1TX) and 2 (CAN1RX) additionally to the existing CAN0.
My init procedure is basically copy paste from the already working CAN0 which is taken from the can_loopback example i think.
void
can_init(void)
{
#if (CAN0_ACTIVE==1)
// Configure the GPIO pin muxing to select CAN0 functions for these pins.
// This step selects which alternate function is available for these pins.
// This is necessary if your part supports GPIO pin function muxing.
// Consult the data sheet to see which functions are allocated per pin.
GPIOPinConfigure(GPIO_PB4_CAN0RX);
GPIOPinConfigure(GPIO_PB5_CAN0TX);
// Enable the alternate function on the GPIO pins. The above step selects
// which alternate function is available. This step actually enables the
// alternate function instead of GPIO for these pins.
GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5);
// The GPIO port and pins have been set up for CAN. The CAN peripheral
// must be enabled.
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
// Initialize the CAN controller
CANInit(CAN0_BASE);
// Setup CAN to be clocked off the M3/Master subsystem clock
CANClkSourceSelect(CAN0_BASE, CAN_CLK_M3);
// Set up the bit rate for the CAN bus. This function sets up the CAN
// bus timing for a nominal configuration. You can achieve more control
// over the CAN bus timing by using the function CANBitTimingSet() instead
// of this one, if needed.
// In this example, the CAN bus is set to 500 kHz. In the function below,
// the call to SysCtlClockGet() is used to determine the clock rate that
// is used for clocking the CAN peripheral. This can be replaced with a
// fixed value if you know the value of the system clock, saving the extra
// function call. For some parts, the CAN peripheral is clocked by a fixed
// 8 MHz regardless of the system clock in which case the call to
// SysCtlClockGet() should be replaced with 8000000. Consult the data
// sheet for more information about CAN peripheral clocking.
CANBitRateSet(CAN0_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED), 500000);
// Enable the CAN for operation.
CANEnable(CAN0_BASE);
#endif
#if (CAN1_ACTIVE==1)
// Configure the GPIO pin muxing to select CAN0 functions for these pins.
// This step selects which alternate function is available for these pins.
// This is necessary if your part supports GPIO pin function muxing.
// Consult the data sheet to see which functions are allocated per pin.
GPIOPinConfigure(GPIO_PB2_CAN1RX);
GPIOPinConfigure(GPIO_PB0_CAN1TX);
// Enable the alternate function on the GPIO pins. The above step selects
// which alternate function is available. This step actually enables the
// alternate function instead of GPIO for these pins.
GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_0);
// The GPIO port and pins have been set up for CAN. The CAN peripheral
// must be enabled.
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);
// Initialize the CAN controller
CANInit(CAN1_BASE);
// Setup CAN to be clocked off the M3/Master subsystem clock
CANClkSourceSelect(CAN1_BASE, CAN_CLK_M3);
// Set up the bit rate for the CAN bus. This function sets up the CAN
// bus timing for a nominal configuration. You can achieve more control
// over the CAN bus timing by using the function CANBitTimingSet() instead
// of this one, if needed.
// In this example, the CAN bus is set to 500 kHz. In the function below,
// the call to SysCtlClockGet() is used to determine the clock rate that
// is used for clocking the CAN peripheral. This can be replaced with a
// fixed value if you know the value of the system clock, saving the extra
// function call. For some parts, the CAN peripheral is clocked by a fixed
// 8 MHz regardless of the system clock in which case the call to
// SysCtlClockGet() should be replaced with 8000000. Consult the data
// sheet for more information about CAN peripheral clocking.
CANBitRateSet(CAN1_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED), 500000);
// Enable the CAN for operation.
CANEnable(CAN1_BASE);
#endif
The cyclic part that handles the messages is running in a task without any usage of interrupts for the CAN and already worked well with CAN0.
void canTask(void)
{
//Tx Messages (We send to external CAN device)
sTXCAN_1.ulMsgID = 0x1; // CAN message ID
sTXCAN_1.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_1.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_1.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_1); // size of message in byte
sTXCAN_1.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_1; // ptr to message content
sTXCAN_2.ulMsgID = 0x2; // CAN message ID
sTXCAN_2.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_2.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_2.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_2); // size of message in byte
sTXCAN_2.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_2; // ptr to message content
sTXCAN_3.ulMsgID = 0xAF; // CAN message ID
sTXCAN_3.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_3.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_3.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_3); // size of message in byte
sTXCAN_3.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_3; // ptr to message content
sTXCAN_4.ulMsgID = 0xC2; // CAN message ID
sTXCAN_4.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_4.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_4.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_4); // size of message in byte
sTXCAN_4.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_4; // ptr to message content
sTXCAN_5.ulMsgID = 0xB0; // CAN message ID
sTXCAN_5.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_5.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_5.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_5); // size of message in byte
sTXCAN_5.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_5; // ptr to message content
sTXCAN_6.ulMsgID = 0xA1; // CAN message ID
sTXCAN_6.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_6.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_6.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_6); // size of message in byte
sTXCAN_6.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_6; // ptr to message content
sTXCAN_7.ulMsgID = 0xA2; // CAN message ID
sTXCAN_7.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_7.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_7.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_7); // size of message in byte
sTXCAN_7.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_7; // ptr to message content
sTXCAN_8.ulMsgID = 0xA3; // CAN message ID
sTXCAN_8.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_8.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_8.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_8); // size of message in byte
sTXCAN_8.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_8; // ptr to message content
sTXCAN_9.ulMsgID = 0xA4; // CAN message ID
sTXCAN_9.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_9.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_9.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_9); // size of message in byte
sTXCAN_9.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_9; // ptr to message content
sTXCAN_10.ulMsgID = 0xA5; // CAN message ID
sTXCAN_10.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_10.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_10.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_10); // size of message in byte
sTXCAN_10.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_10; // ptr to message content
sTXCAN_11.ulMsgID = 0xA7; // CAN message ID
sTXCAN_11.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_11.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_11.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_11); // size of message in byte
sTXCAN_11.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_11; // ptr to message content
sTXCAN_12.ulMsgID = 0xB1; // CAN message ID
sTXCAN_12.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_12.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_12.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_12); // size of message in byte
sTXCAN_12.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_12; // ptr to message content
sTXCAN_13.ulMsgID = 0xB2; // CAN message ID
sTXCAN_13.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_13.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_13.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_13); // size of message in byte
sTXCAN_13.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_13; // ptr to message content
sTXCAN_14.ulMsgID = 0xB3; // CAN message ID
sTXCAN_14.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_14.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_14.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_14); // size of message in byte
sTXCAN_14.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_14; // ptr to message content
sTXCAN_15.ulMsgID = 0xD7; // CAN message ID
sTXCAN_15.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_15.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_15.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_15); // size of message in byte
sTXCAN_15.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_15; // ptr to message content
sTXCAN_16.ulMsgID = 0xFA; // CAN message ID
sTXCAN_16.ulMsgIDMask = 0; // no mask needed for TX
sTXCAN_16.ulFlags = MSG_OBJ_TX_INT_ENABLE; // enable interrupt on TX
sTXCAN_16.ulMsgLen = sizeof(c28_to_m3_shadow.CAN_C28_to_M3.send_16); // size of message in byte
sTXCAN_16.pucMsgData = (unsigned char*) &c28_to_m3_shadow.CAN_C28_to_M3.send_16; // ptr to message content
//Rx Messages (We get from external CAN device)
sRXCAN_1.ulMsgID = 0x3; // CAN message ID
sRXCAN_1.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_1.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_1.ulMsgLen = 8; // size of message in byte
sRXCAN_1.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_1; // ptr to message content
sRXCAN_2.ulMsgID = 0x4; // CAN message ID
sRXCAN_2.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_2.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_2.ulMsgLen = 8; // size of message in byte
sRXCAN_2.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_2; // ptr to message content
sRXCAN_3.ulMsgID = 0x5; // CAN message ID
sRXCAN_3.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_3.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_3.ulMsgLen = 8; // size of message in byte
sRXCAN_3.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_3; // ptr to message content
sRXCAN_4.ulMsgID = 0x6; // CAN message ID
sRXCAN_4.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_4.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_4.ulMsgLen = 8; // size of message in byte
sRXCAN_4.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_4; // ptr to message content
sRXCAN_5.ulMsgID = 0x7; // CAN message ID
sRXCAN_5.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_5.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_5.ulMsgLen = 8; // size of message in byte
sRXCAN_5.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_5; // ptr to message content
sRXCAN_6.ulMsgID = 0x9; // CAN message ID
sRXCAN_6.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_6.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_6.ulMsgLen = 8; // size of message in byte
sRXCAN_6.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_6; // ptr to message content
sRXCAN_7.ulMsgID = 0x10; // CAN message ID
sRXCAN_7.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_7.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_7.ulMsgLen = 8; // size of message in byte
sRXCAN_7.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_7; // ptr to message content
sRXCAN_8.ulMsgID = 0x11; // CAN message ID
sRXCAN_8.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_8.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_8.ulMsgLen = 8; // size of message in byte
sRXCAN_8.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_8; // ptr to message content
sRXCAN_9.ulMsgID = 0x12; // CAN message ID
sRXCAN_9.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_9.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_9.ulMsgLen = 8; // size of message in byte
sRXCAN_9.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_9; // ptr to message content
sRXCAN_10.ulMsgID = 0x13; // CAN message ID
sRXCAN_10.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_10.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_10.ulMsgLen = 8; // size of message in byte
sRXCAN_10.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_10; // ptr to message content
sRXCAN_11.ulMsgID = 0x14; // CAN message ID
sRXCAN_11.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_11.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_11.ulMsgLen = 8; // size of message in byte
sRXCAN_11.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_11; // ptr to message content
sRXCAN_12.ulMsgID = 0x15; // CAN message ID
sRXCAN_12.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_12.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_12.ulMsgLen = 8; // size of message in byte
sRXCAN_12.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_12; // ptr to message content
sRXCAN_13.ulMsgID = 0x16; // CAN message ID
sRXCAN_13.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_13.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_13.ulMsgLen = 8; // size of message in byte
sRXCAN_13.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_13; // ptr to message content
sRXCAN_14.ulMsgID = 0x17; // CAN message ID
sRXCAN_14.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_14.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_14.ulMsgLen = 8; // size of message in byte
sRXCAN_14.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_14; // ptr to message content
sRXCAN_15.ulMsgID = 0x18; // CAN message ID
sRXCAN_15.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_15.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_15.ulMsgLen = 8; // size of message in byte
sRXCAN_15.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_15; // ptr to message content
sRXCAN_16.ulMsgID = 0x19; // CAN message ID
sRXCAN_16.ulMsgIDMask = 0; // no mask needed for TX
sRXCAN_16.ulFlags = MSG_OBJ_NO_FLAGS; //
sRXCAN_16.ulMsgLen = 8; // size of message in byte
sRXCAN_16.pucMsgData = (unsigned char*) &m3_to_c28.CAN_M3_to_C28.receive_16; // ptr to message content
while(1)
{
gCANSendCnt1++;
gCANSendCnt2++;
// Setup the message object being used to receive messages
CANMessageSet(CAN1_BASE, 1, &sRXCAN_1, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 2, &sRXCAN_2, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 3, &sRXCAN_3, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 4, &sRXCAN_4, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 5, &sRXCAN_5, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 6, &sRXCAN_6, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 7, &sRXCAN_7, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 8, &sRXCAN_8, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 9, &sRXCAN_9, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 10, &sRXCAN_10, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 11, &sRXCAN_11, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 12, &sRXCAN_12, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 13, &sRXCAN_13, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 14, &sRXCAN_14, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 15, &sRXCAN_15, MSG_OBJ_TYPE_RX);
CANMessageSet(CAN1_BASE, 16, &sRXCAN_16, MSG_OBJ_TYPE_RX);
// wait until the next message cycle is triggered by c28
Semaphore_pend(semaphore_CAN, BIOS_WAIT_FOREVER);
/* CAN SEND MSG WITH CAN_SEND1_INTERVAL */
// Update TX Messages 1 every x ms
if (gCANSendCnt1 % CAN_SEND_INTERVAL_1 == 0) {
gCANSendCnt1 = 0;
static Uint64 CAN_Send1_alive_cnt = 0;
CAN_Send1_alive_cnt++;
c28_to_m3_shadow.CAN_C28_to_M3.send_16 = CAN_Send1_alive_cnt;
// Send the CAN message using object number 1 (not the same thing as
// CAN ID). There are 32 objects (1-32) available. This function will cause
// the message to be transmitted right away.
CANMessageSet(CAN1_BASE, 17, &sTXCAN_1, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 18, &sTXCAN_2, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 19, &sTXCAN_3, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 20, &sTXCAN_4, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 21, &sTXCAN_5, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 22, &sTXCAN_6, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 23, &sTXCAN_7, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 24, &sTXCAN_8, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 25, &sTXCAN_9, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 26, &sTXCAN_10, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 27, &sTXCAN_11, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 28, &sTXCAN_12, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 29, &sTXCAN_13, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 30, &sTXCAN_14, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 31, &sTXCAN_15, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 32, &sTXCAN_16, MSG_OBJ_TYPE_TX);
}
/* CAN SEND MSG WITH CAN_SEND2_INTERVAL */
// Update TX Messages 2 every x ms
if (gCANSendCnt2 % CAN_SEND_INTERVAL_2 == 0) {
gCANSendCnt2 = 0;
static Uint64 CAN_Send2_alive_cnt = 0;
CAN_Send2_alive_cnt++;
c28_to_m3_shadow.CAN_C28_to_M3.send_15 = CAN_Send2_alive_cnt;
// Send the CAN message using object number 1 (not the same thing as
// CAN ID). There are 32 objects (1-32) available. This function will cause
// the message to be transmitted right away.
// CANMessageSet(CAN1_BASE, 17, &sTXCAN_1, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 18, &sTXCAN_2, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 19, &sTXCAN_3, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 20, &sTXCAN_4, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 21, &sTXCAN_5, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 22, &sTXCAN_6, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 23, &sTXCAN_7, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 24, &sTXCAN_8, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 25, &sTXCAN_9, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 26, &sTXCAN_10, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 27, &sTXCAN_11, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 28, &sTXCAN_12, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 29, &sTXCAN_13, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 30, &sTXCAN_14, MSG_OBJ_TYPE_TX);
CANMessageSet(CAN1_BASE, 31, &sTXCAN_15, MSG_OBJ_TYPE_TX);
// CANMessageSet(CAN1_BASE, 32, &sTXCAN_16, MSG_OBJ_TYPE_TX);
}
//alive counter
alive_ctr = alive_ctr + 1;
if(alive_ctr >= 100)
alive_ctr = 1;
CANMessageGet(CAN1_BASE, 1, &sRXCAN_1, true);
CANMessageGet(CAN1_BASE, 2, &sRXCAN_2, true);
CANMessageGet(CAN1_BASE, 3, &sRXCAN_3, true);
CANMessageGet(CAN1_BASE, 4, &sRXCAN_4, true);
CANMessageGet(CAN1_BASE, 5, &sRXCAN_5, true);
CANMessageGet(CAN1_BASE, 6, &sRXCAN_6, true);
CANMessageGet(CAN1_BASE, 7, &sRXCAN_7, true);
CANMessageGet(CAN1_BASE, 8, &sRXCAN_8, true);
CANMessageGet(CAN1_BASE, 9, &sRXCAN_9, true);
CANMessageGet(CAN1_BASE, 10, &sRXCAN_10, true);
CANMessageGet(CAN1_BASE, 11, &sRXCAN_11, true);
CANMessageGet(CAN1_BASE, 12, &sRXCAN_12, true);
CANMessageGet(CAN1_BASE, 13, &sRXCAN_13, true);
CANMessageGet(CAN1_BASE, 14, &sRXCAN_14, true);
CANMessageGet(CAN1_BASE, 15, &sRXCAN_15, true);
CANMessageGet(CAN1_BASE, 16, &sRXCAN_16, true);
IPCMtoCFlagSet(IPC_FLAG6); // benachrichtige c28 -> neue Daten
}
}
Now i simply tried to send and receive all messages which were handled over CAN0 now with CAN1, as can be seen in the code above but the signal on the CAN1TX pin seems very strange to me.
First a picture of the CAN0TX line when all those messages are sent via CAN0 (blue signal):

Then when i send all those messages via CAN1 i would assume the signal to look identical to the one formerly sent via CAN0, but it looks like this (red signal, shifted minus 5 Volts on the scope):

To me this looks not like a CAN message, more like a perfect 16 kHz PWM signal.
Can somebody explain the bahviour? Is something wrong with the init procedure?
I already checked, that the CAN1 pins are controlled by the M3 core and not by the C28.
I also checked if the PB0 and PB2 pin are initialized somewhere else in the code and found nothing.
I cleaned the project and rebuilt it already.
I really do not know how to proceed. Anybody out there with a good advice?
Thx a lot
Michael