Thread 中讨论的其他器件:controlSUITE
您好!
我正在使用 M3内核并使用 GPIO_PB4 (CAN0RX)和5 (CAN0TX)上的 CAN0接口。 到目前为止、这种方法效果非常好。
现在、我需要第二个 CAN 接口、只需在现有的 CAN0基础上使用 GPIO_PB0 (CAN1TX)上的 CAN1和2 (CAN1RX)上的 CAN1。
我的初始化过程基本上是从已经在工作的 CAN0复制粘贴、我认为这是从 CAN_loopback 示例中获取的。
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
处理消息的循环部分正在任务中运行、而不使用 CAN 的任何中断、并且已经与 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
}
}
现在、我只是尝试发送和接收所有通过 CAN0处理的消息、现在使用 CAN1、正如上面的代码所示、但 CAN1TX 引脚上的信号对我来说似乎非常奇怪。
首先是 CAN0TX 线路的图片、当所有这些消息都通过 CAN0 (蓝色信号)发送时:

然后、当我通过 CAN1发送所有这些消息时、我假设该信号看起来与之前通过 CAN0发送的信号相同、但它看起来是这样的(红色信号、示波器上的偏移负5V):

在我看来、这看起来不像 CAN 消息、更像是完美的16kHz PWM 信号。
有人能解释一下这个巴维霍尔吗? 初始化过程是否有问题?
我已经检查了 CAN1管脚是否由 M3内核控制、而不是由 C28控制。
我还检查了 PB0和 PB2引脚是否在代码中的其他位置被初始化、没有发现任何内容。
我清理了项目并重建了它。
我真的不知道如何继续。 有人提出了好的建议吗?
这是非常多的
Michael