MKE18F512 flex_can settings for CANopen

cancel
Showing results for 
Search instead for 
Did you mean: 

MKE18F512 flex_can settings for CANopen

206 Views
gp2004
Contributor I

Hello all,

I am currently working on a project which requires me to use the flex_can feature on MKE18F512 chip. This project also requires CANopen communication protocal.

Now I made the CAN bus to work, but if I want to use CANopen protocol, I have to disable/clear the ID filters in order to process different incoming CANopen COB_IDs. The problem is, when I have the ID filters cleared, I am receiving a lot of 0x00 messages which are completly garbage and it's a waste of all the resources. 

I am wondering if there is any way I can make the filter work as a non-zero message checker. Or, if there is any other example of implementing CANopen protocol on any similar chip, I would be happy to learn from.

Thank you,

Peng

Labels (1)
0 Kudos
3 Replies

107 Views
mjbcswitzerland
Specialist V

Hi

I am not very experienced with CANopen but have used the following CANopen configuration in the uTasker project

#define CANOPEN_RX_NODE_ID                  0x7a                         // we receive this node-ID
#define CANOPEN_TX_NODE_ID                  0x37                         // this is the node-ID hat we use when transmitting

static QUEUE_HANDLE fnInitCANopenInterface(void)
{
    CANTABLE tCANParameters;                                             // table for passing information to driver
    QUEUE_HANDLE CANopenHandle;

    tCANParameters.Task_to_wake = OWN_TASK;                              // wake us on buffer events
    tCANParameters.Channel = 0;                                          // CAN0 interface
    tCANParameters.ulSpeed = 250000;                                     // 250k speed
    tCANParameters.ulTxID = (121);                                       // default ID of destination (not used by CANopen)
    tCANParameters.ulRxID = (CAN_EXTENDED_ID | 0x00080000 | CANOPEN_RX_NODE_ID); // extended node ID that we receive
    tCANParameters.ulRxIDMask = (0x00080000 | CANOPEN_RX_NODE_ID);       // receive extended address with 0x80000 set and exactly matching the node ID
    tCANParameters.usMode = 0;                                           // use normal mode
    tCANParameters.ucTxBuffers = 2;                                      // assign two tx buffers for use
    tCANParameters.ucRxBuffers = 1;                                      // assign one rx buffers for extended ID use
    CANopenHandle = fnOpen(TYPE_CAN, FOR_I_O, &tCANParameters);          // open CAN interface
    tCANParameters.ulRxID = 0;                                           // broadcast address
    tCANParameters.ulRxIDMask = CAN_STANDARD_MASK;                       // accept ID 0
    tCANParameters.ucTxBuffers = 0;
    tCANParameters.ucRxBuffers = 1;
    fnConfigCAN(CANopenHandle, &tCANParameters);                         // configure 1 buffer for this logical channel
    tCANParameters.ulRxID = CANOPEN_RX_NODE_ID;                          // node ID that we receive
    tCANParameters.ulRxIDMask = 0x7f;                                    // accept only exact node ID
    tCANParameters.ucRxBuffers = 1;
    fnConfigCAN(CANopenHandle, &tCANParameters);                         // configure 1 buffer for this logical channel
    return CANopenHandle;                                                // open CAN interface
}

This is used to receive exact CANopen extended IDs and standard IDs on the rx node 0x7a (for example) - one filter for each - then one filter for the broadcast (ID 0).
Anything else is rejected.

Can you specify exactly which IDs you need to filter?

Regards

Mark

Complete Kinetis solutions for professional needs, training and support:http://www.utasker.com/kinetis.html
Kinetis KE1xF:
- http://www.utasker.com/kinetis/FRDM-KE15Z.html
- http://www.utasker.com/kinetis/TWR-KE18F.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html

0 Kudos

107 Views
gp2004
Contributor I

Hi Mark,

Thank you for your help.

I am receiving a lot of 0x00 messages when I have the filters set to null (0). 

Right now I am looking for a way to set the filters to filter out all the 0x00 messages and keep the rest. 

We don't have all the exact IDs we want yet, so we'd like to keep the receving hardware filter open and just do the application layer filter by hand.

Regards,

Peng

0 Kudos

107 Views
mjbcswitzerland
Specialist V

Hi

ID 0 is a CANopen broadcast ID so it can't be filtered without inhibiting CANopen operation: Therefore I am not sure that you have a problem with the filter.

However if you are not yet using any filtering it would be normal that you receive lots of messages (all) if these are present on the bus. As you mention, you can filter in the firmware too, if you don't mind the overhead.

Regards

Mark

0 Kudos