Skip to main content
Explorer II
August 13, 2025
Solved

CAN communication only working when the reciever is reset?

  • August 13, 2025
  • 3 replies
  • 1541 views

The goal of my project is to turn on an LED on the recieving side through CAN. Both my reciever and transmitter have the transciever circuit. Both are Nucleo boards, TX: F303RE, RX: F446RE.

The data i am sending through is 16-bit, but as long as my reciever is not in reset copnstantly (as in me holding the reset button when the program is running), the transmitted and recieved data is not correct, its far to short. The data is the same on TX and RX, but wrong. But when i hold reset on the reciever the data that comes through looks right. 

I cant figure out what the problem is, i have measured the connections on the transcievers a million times, measured the RX, TX pin, CAN_H and L and always come back to the same issue. 

I am programming the boards in Cube_IDE. The pictures below are of the boards and the signals i recieve. Please help. I dont see how this could be a hardware problem but maybe I missed something, i am still a begginer. 

 

The reciever board is part of another project, but i used it, since it has the transciever circuit and that way there was no soldering needed. And the reciver board worked on the previous project of my friend.

The boards

tim_licen123_0-1755069761730.jpeg

The signal when the RX is not reset:

tim_licen123_1-1755069806967.jpeg

The signal when it is reset:

tim_licen123_2-1755069830704.jpeg

Any help is appreciated ! The codes i put as txt files. 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    1- However I'm wondering how F446 is reading CAN data?! You have this filter configuration for CAN1:

     cancanfilter.FilterBank = 10;
     cancanfilter.SlaveStartFilterBank = 0;

    SlaveStartFilterBank = 0 means all the filters are allocated to CAN2 which is not used!

    Refer to this article: STM32 in dual CAN configuration: bxCAN Filter bank explanation and relation with CAN2 Start Bank parameter : "If SlaveStartFilterBank = 0: all filters are allocated to CAN2. In that case CAN1 is not usable, but CAN1 APB clock should be enabled since it is a master as mentioned previously."

    In the case of CAN1 instance, SlaveStartFilterBank needs to be > FilterBank

    2- For F3:

    You have an issue with the filter setting especially the FIFO number. You seems using FIFO1 but you are setting FIFO0 for the filter:

    cancanfilter.FilterFIFOAssignment = CAN_FILTER_FIFO0;

    Change it as the following:

    cancanfilter.FilterFIFOAssignment = CAN_FILTER_FIFO1;

     

    3 replies

    Graduate II
    August 13, 2025

    As a first try if you have a CAN tool use it and verify if the messages that are transmitted are received properly on the tool and then you can go in steps of transmitting messages from the tool etc.

    Explorer II
    August 13, 2025

    I dont have a CAN tool. I have an osciloscope. I have verified that i recieve the same message that i transmitt. I have also noticed another problem, my TX stops sending data after a period of time and needs a reset, then it starts sending data (wrong data again). Hope this maybe is a useful clue. Thanks for replying !

     

    Graduate II
    August 13, 2025

    The truncated message is probably because there is an error on the BUS.
    1) Do You have the 2 x 120R termination resistors on the Bus?
    2) If Yes then You probably have different baud-rates on the two nods (or CAN-H and CAN-L inverted).
    P.S. To have a stable CAN-Bus you should use an external crystal or oscillator, the HSI oscillator is not suitable because of the frequency tolerance.

    Explorer II
    August 20, 2025

    Now i tottaly redid the code and the issue is, I never recieve data/enter the interrupt?. On the reciever, the data on the TX pin is the same as on the transmitter, but on the RX pin, there is just one single pulse from logic high to low, what could be the issue here. It seems as if I transmit data to the TX pin instead of the RX pin? 

    Please help, bellow is the main.c, for my reciever. The TX part now works perfectly, with no need to reset anything, now the problem is not recieving the data. 

     

     

    Graduate II
    August 20, 2025

    Generally if there are no hardware issues two possibilities are

    a. Baud rate mismatch

    b. Improper filter configuration

    Check the above two then you may solve the problem.

    Explorer II
    August 21, 2025

    Here are the projects. The 303 doesnt read the data correcty, but the sending works. 

    mƎALLEmAnswer
    Technical Moderator
    August 21, 2025

    Hello,

    1- However I'm wondering how F446 is reading CAN data?! You have this filter configuration for CAN1:

     cancanfilter.FilterBank = 10;
     cancanfilter.SlaveStartFilterBank = 0;

    SlaveStartFilterBank = 0 means all the filters are allocated to CAN2 which is not used!

    Refer to this article: STM32 in dual CAN configuration: bxCAN Filter bank explanation and relation with CAN2 Start Bank parameter : "If SlaveStartFilterBank = 0: all filters are allocated to CAN2. In that case CAN1 is not usable, but CAN1 APB clock should be enabled since it is a master as mentioned previously."

    In the case of CAN1 instance, SlaveStartFilterBank needs to be > FilterBank

    2- For F3:

    You have an issue with the filter setting especially the FIFO number. You seems using FIFO1 but you are setting FIFO0 for the filter:

    cancanfilter.FilterFIFOAssignment = CAN_FILTER_FIFO0;

    Change it as the following:

    cancanfilter.FilterFIFOAssignment = CAN_FILTER_FIFO1;