just wondering if anyone could have a quick look at the following snippet and see if I am making any glaring errors with relation to the configuration of the canbus module on PIC 18f4580,
messages are standard length, clock is 16mhz, baud should be 500kbps as it;s for powertrain canbus - everything seems to work, interrupt triggers, valid canbus messages are received however the filters are not operative, i.e i am reading all data on the bus, where I want to specifically listen for ID's with 0x7E8
I feel my error is likely a naive/daft one but I can't see it
Code: Select all
CANSetOperationMode(_CAN_MODE_CONFIG, 0xFF);
//set config flags
CAN_TX_BAUD_FLAGS = _CAN_CONFIG_SAMPLE_THRICE &
_CAN_CONFIG_PHSEG2_PRG_OFF &
_CAN_CONFIG_STD_MSG &
_CAN_CONFIG_DBL_BUFFER_OFF &
_CAN_CONFIG_LINE_FILTER_OFF;
//set baud rate
CANInitialize(1,2,1,2,4, CAN_TX_BAUD_FLAGS);
//set filters
CANSetFilter(_CAN_FILTER_B1_F1, 0x7E8, _CAN_CONFIG_STD_MSG);
CANSetFilter(_CAN_FILTER_B1_F2, 0x7E8, _CAN_CONFIG_STD_MSG);
CANSetFilter(_CAN_FILTER_B2_F1, 0x7E8, _CAN_CONFIG_STD_MSG);
CANSetFilter(_CAN_FILTER_B2_F2, 0x7E8, _CAN_CONFIG_STD_MSG);
CANSetFilter(_CAN_FILTER_B2_F3, 0x7E8, _CAN_CONFIG_STD_MSG);
CANSetFilter(_CAN_FILTER_B2_F4, 0x7E8, _CAN_CONFIG_STD_MSG);
CANSetMask(_CAN_MASK_B1, 0x1FFFFFFF, _CAN_CONFIG_STD_MSG);
CANSetMask(_CAN_MASK_B2, 0x1FFFFFFF, _CAN_CONFIG_STD_MSG);
CANSetOperationMode(_CAN_MODE_NORMal, 0xFF);
PIE3.b1 = 1; PIE3.B0 = 1;