CAN on vf50

Hi all,

I’m trying getting the CAN demo frot he VF50 to run.
I have the latest WEC2013 v1.4Beta 1 running on a Viola Carrier board. I using the latest lib version 1.8

In the CAN demo I call Can_Init with “CAN1” instead of “SPI2”
The “Implementation” is also set to “FlexCAN”.

Calling Can_SetConfigString(hCan, L"Interface", L"CAN1", StoreVolatile); makes the debugger hit an exception. I guess the param name Implementation has been removed from the latest lib version 1.8?

When I try to receive a frame the Can_Read(...) the begugger breaks after the 5 second timeout. No exception type is shown. Only it has reached a breakpoint.

The execution than halts!!

Any suggestion what I have missed?

Below is here the code:

    hCan = Can_Init(L"CAN1"); // Internal CAN
    //hCan = Can_Init(L"SPI2");
    if (hCan == NULL)
        printf("Error in CAN initialization\r\n");
    returnValue = Can_SetConfigString(hCan, L"Implementation", L"FlexCAN",        StoreVolatile); 
    returnValue = Can_SetConfigString(hCan, L"FrameFormat",    L"standard",     StoreVolatile);   
    returnValue = Can_SetConfigString(hCan, L"FilterRemote",   L"none",     StoreVolatile);   
    returnValue = Can_SetConfigString(hCan, L"RtrFormat",      L"data",     StoreVolatile);  
    returnValue = Can_SetConfigInt(hCan, L"FilterID",   0x00,       StoreVolatile);    
    returnValue = Can_SetConfigInt(hCan, L"FilterMask", 0x00,       StoreVolatile);    
	returnValue = Can_SetConfigInt(hCan, L"SingleThread", 0,       StoreVolatile);     
    returnValue = Can_SetConfigInt(hCan, L"BitRateHz", 125000, StoreVolatile);

 // Configure timeout to 5 sec, by default it is set to 1 sec
    Can_SetConfigInt(hCan, L"Timeout", 5000, StoreVolatile);    // optional

    // 3. Apply configuration to hardware
    if (!Can_Open(hCan))
        printf("CAN Rx Open failed\r\n");
        return 0;

    // 4. Use CAN
    canBuf.dataLen = 8;
    if (Can_Read(hCan, &canBuf)) << BANG! After 5 second timeout

Have some additional info. From debug output:

Unknown: DEBUGCHK failed in file .\src\can_flex.c at line 245
CANDemo.exe has triggered a breakpoint.

CAN Error: Timeout occurred


I figured it out myself…
I have to set the CAN RX/TX pins also…

           uIo ioRx =  COLIBRI_PIN(63);
            uIo ioTx =  COLIBRI_PIN(55);
    	Can_SetConfigInt(hCan, L"ioRx", ioRx.GenericDefinition, StoreVolatile);
    	Can_SetConfigInt(hCan, L"ioTx", ioTx.GenericDefinition, StoreVolatile);

This did the trick…

Actually, COLIBRI_PIN(63) and COLIBRI_PIN(55) are CAN2 pins in Vybrid and the same pins used for CAN1 in iMX6. To make the program easier, the library will decide CAN interface by ioRx and ioTx pins, it is more priority than the portName. If an application is setting ioRx and ioTX pins then the corresponding CAN interface will be used by the library.