2016-11-03 11:17 AM
2016-11-03 02:06 PM
Hello karbasi.ghasem,
After reading your request the second time, I realized I've given you an improper answer!The CAN interface is a bit tougher to get running! Steps I follow while debugging CAN:Make sure your timing configuration is the same for all devices on the bus!It's highly recommended to use an external crystal in case of CAN (timing precision is important)You are not checking the results of your functions. Filter init, CAN init etc. How can you be sure the outcome is ok?After CAN is initialized, make sure you are in Normal mode (nor sleep, nor init)You are in Silent mode, transmission is not working/allowed, you are able only to receive.I see you are calling the HAL_CAN_Receive() function, but before you are checking whether there are some pending messages. This check is in my opinion in the HAL_CAN_Receive() function... don't have the library downloaded, you need to check it.Are you sure you are calling the HAL_CAN_Receive() function or you always return because pending bit is false? You don't check the outcome, set some return values to be able to debug it...The CAN has some error registers, try to check these to make sure the bus is not in some error state (there is an error counter inside indicating the state).I hope my answer helps you to move forward.Have a nice day,Renegade2016-11-03 11:56 PM
hello ,
thank you for answering,1- i am use 16MHZ external clock2-i am CAR ECU always Online Mode and send Repeated frame so not need check with debugger and 500kbps fix baud rate3-i am check init function and all register such as SLAK INAK ,MCR TSR MSR is OK and SET correctly and HAL_OK Result.4-check frame signal with oscilloscope and not frame signal on can tx pin5-test loopback mode and normal mode and in loopback mode received frame with have a PENDING function but in normal mode nothing intended purpose no recieve,no send2016-11-07 06:08 PM
Hey there,
the point 5 is insteresting. How is it possible that you receive message in loopback mode, but not in normal mode? Have you measured the data on RX pin (on MCU) in normal/silent mode? Have you measured the data on TX/RX while in loopback mode? If you receive back data in loopback mode, it proves the MCU transmits data over the bus and receives them back. So I would double check the HW. Renegade