M400 CAN Bus and PIC32 Microcontroller

Discussion and support for MoTeC's previous generation ECUs.

M400 CAN Bus and PIC32 Microcontroller

Postby carbon on Tue Dec 04, 2012 10:27 am

Hello,

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.
carbon
 
Posts: 2
Joined: Wed Nov 28, 2012 11:06 am

Re: M400 CAN Bus and PIC32 Microcontroller

Postby Polux RSV on Thu Dec 06, 2012 8:02 am

Code: Select all
// 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);


Is CAN_BUS_SPEED set at 1'000'000 in another source or header file?

Masks and filters are the most difficult part of can. First try to receive anything on your board by disabling any filters und masks. When you have reception working, activate masks and filters.

Hope this helps

Angelo
Polux RSV
 
Posts: 90
Joined: Wed Feb 18, 2009 4:18 am

Re: M400 CAN Bus and PIC32 Microcontroller

Postby carbon on Fri Dec 07, 2012 11:08 am

Sorry that was a typo, the real speed is set to 1,000,000 to set it to 1 Mbit/s. I have tried turning off all filters and mask to receive data with no luck. Someone mentioned it may be a timing problem. I am going to try with a different timing scheme that Microchip recommends. Any other ideas as to whats wrong?

Thanks,
carbon
carbon
 
Posts: 2
Joined: Wed Nov 28, 2012 11:06 am


Return to M400, M600, M800 and M880 ECUs

Who is online

Users browsing this forum: Bing [Bot] and 33 guests