stm32f7 CAN: loop-back communication on CAN1 and CAN2

    Struggling three days on CAN communication, tons of CAN protocol to read, but I prefer creating new project on STM32 than reading papers alone, with the reference of STM32Cube and searched information on-line, I upload my project of loop-back on CAN1 and CAN2, here is the linkage:

https://download.csdn.net/download/cutelily2014/10422962

    The most confusing point is the configuration of CAN2, as  CAN2 is not totally independent as CAN1, in other words, CAN2 rely on CAN1. Once you want set up CAN1 to communicate with some devices, it's easy to copy a standard example from ST cube, etc. but once you want set up CAN2 for communication, you have to take care of following parameter:

1) Open CAN1 clock before CAN2 clock

2) Set CAN2 filter bank number to 0

you can find above two settings in line 110 of stm32f7xx_hal_msp.c and line 263 of main.cpp .

    Finally, hope this project is helpful.

你可能感兴趣的:(stm32)