STM32_CAN
STM32_CAN copied to clipboard
After first call of Can1.write(CAN_TX_msg); my stm32 sends the same CAN_TX_msg forever.
I'm using an STM32F103C8 with stm32duino on the Arduino IDE and programming over st-link V2. My code is almost the same as the write example, I have only switched STM32_CAN Can1( CAN1, DEF );
to be STM32_CAN Can1( CAN1, ALT );
to match the CAN pins I am using and I have removed all calls to Serial because I am not using USB. Here is my board setup:
When I upload the example code my STM32 does send out CAN frames, but they are all identical and repeating with about a 100us gap between frames. The message I read with my logic analyzer is ID: 0x1A5 DLC: 0x8 Data: 0x03 0x41 0x11 0x00 0x00 0x00 0x00 0x00 CRC: 0x640B NAK
which is consistent with what CAN_TX_msg is set to when Can1.write() is called for the first time.
Any ideas what is causing this? Thank you.
@BotSpace Hmmn sounds like you don't have the receiving end there and by default the automatic retransmission is enabled. You can disable it by changing Can.begin();
to Can.begin(false);
Yes, I should add some description about all the possible parameters in the library and how/when to use those.