I am trying to read data from a Motec M400 with a PIC32 dev board with a CAN transreceiver. M400 is set to Custom data set 1 according to the directions on this page: http://www.race-technology.com/wiki/index.php/ECUType/MotecM400M600M800CAN and I have set the CAN configuration on the dev board as such:
- Code: Select all
void CAN1Init(void)
{
CAN_BIT_CONFIG canBitConfig;
UINT baudPrescalar;
CANEnableModule(CAN1, TRUE);
CANSetOperatingMode(CAN1, CAN_CONFIGURATION);
while(CANGetOperatingMode(CAN1) != CAN_CONFIGURATION);
// Standard Values
canBitConfig.phaseSeg2Tq = CAN_BIT_3TQ;
canBitConfig.phaseSeg1Tq = CAN_BIT_3TQ;
canBitConfig.propagationSegTq = CAN_BIT_3TQ;
canBitConfig.phaseSeg2TimeSelect = TRUE;
canBitConfig.sample3Time = TRUE;
canBitConfig.syncJumpWidth = CAN_BIT_2TQ;
// Set speed to 1 Mbit/s
// SYSTEM FREQ = 80,000,000 (80 MHz)
// CAN_BUS_SPEED = 100,000
CANSetSpeed(CAN1, &canBitConfig, SYSTEM_FREQ, CAN_BUS_SPEED);
// 256 bytes of storage space
CANAssignMemoryBuffer(CAN1, CAN1MessageFifoArea, (2*8*16));
CANConfigureChannelForTx(CAN1, CAN_CHANNEL0, 8, CAN_TX_RTR_DISABLED,
CAN_LOW_MEDIUM_PRIORITY);
// Configure Filter to read Battery Voltage
CANConfigureChannelForRx(CAN1, CAN_CHANNEL1, 8, CAN_RX_FULL_RECEIVE);
CANConfigureFilter(CAN1, CAN_FILTER0, 0x5F3, CAN_SID);
CANConfigureFilterMask(CAN1, CAN_FILTER_MASK0, 0x7FF, CAN_SID, CAN_FILTER_MASK_IDE_TYPE);
CANLinkFilterToChannel(CAN1, CAN_FILTER0, CAN_FILTER_MASK0, CAN_CHANNEL1);
CANEnableFilter(CAN1, CAN_FILTER0, TRUE);
CANEnableChannelEvent(CAN1, CAN_CHANNEL1, CAN_RX_CHANNEL_NOT_EMPTY, TRUE);
CANEnableModuleEvent(CAN1, CAN_RX_EVENT, TRUE);
INTSetVectorPriority(INT_CAN_1_VECTOR, INT_PRIORITY_LEVEL_4);
INTSetVectorSubPriority(INT_CAN_1_VECTOR, INT_SUB_PRIORITY_LEVEL_0);
INTEnable(INT_CAN1, INT_ENABLED);
CANSetOperatingMode(CAN1, CAN_NORMAL_OPERATION);
while(CANGetOperatingMode(CAN1) != CAN_NORMAL_OPERATION);
}
I am looking at byte positions 4-5 on Channel 11 (battery voltage). However I am not getting any messages with that Message ID, I am not sure why I am not receiving any data since I can hook it up to the computer and read the battery voltage.
Any help on this matter will be appreciated.
Thank you.