TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320F28384S: CAN 报文过滤功能该如何进行配置?

Part Number:TMS320F28384S

我想利用CAN接口的过滤功能,将接收到的CAN扩展帧ID的第17到22位为非零的数据帧过滤掉,不接收处理。我按照datasheet的说明进行了配置,但没有效果。可能是我对datasheet理解的不够深入,请帮我看看配置哪里不正确。谢谢!can的配置如下:

#define CAN_ID_MASK  (0x007E0000U)

//
// Configuring the GPIOs for CAN A.
//
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);

//
CAN_initModule(CANA_BASE);
// Set up the CAN bus bit rate to 500kHz for each module
// Refer to the Driver Library User Guide for information on how to set
// tighter timing control. Additionally, consult the device data sheet
// for more information about the CAN module clocking.
//
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 250000, 20);

//
// Enable interrupts on the CANA peripheral.
//
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
CAN_INT_STATUS);

//
// Initialize PIE and clear PIE registers. Disable CPU interrupts.
//
Interrupt_initModule();

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();

Interrupt_register(INT_CANA0, &canaISR);
// Enable the CAN-A interrupt signal
//
Interrupt_register(INT_CANA0, &canaISR);
Interrupt_enable(INT_CANA0);
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);

//
// Initialize the transmit message object used for sending CAN messages.
// Message Object Parameters:
// CAN Module: A
// Message Object ID Number: 1
// Message Identifier: 0x15555555
// Message Frame: Extended
// Message Type: Transmit
// Message ID Mask: 0x0
// Message Object Flags: None
// Message Data Length: 4 Bytes (Note that DLC field is a "don't care"
// for a Receive mailbox
//
CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x15555555,
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);

// Initialize the receive message object used for receiving CAN messages.
// Message Object Parameters:
// CAN Module: A
// Message Object ID Number: 1
// Message Identifier: 0x15555555
// Message Frame: Extended
// Message Type: Receive
// Message ID Mask: 0x0
// Message Object Flags: Receive Interrupt
// Message Data Length: 4 Bytes
//

#define CAN_ID_MASK (0x007E0000U)
CAN_setupMessageObject(CANA_BASE, RX_MSG_OBJ_ID, 0,
CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, CAN_ID_MASK,
CAN_MSG_OBJ_RX_INT_ENABLE|CAN_MSG_OBJ_USE_EXT_FILTER|CAN_IF1MSK_MDIR|CAN_MSG_OBJ_USE_ID_FILTER, MSG_DATA_LENGTH);
//
// Start CAN module A and B operations
//
CAN_startModule(CANA_BASE);

?? ?:

已解决

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28384S: CAN 报文过滤功能该如何进行配置?
分享到: 更多 (0)