2023-09-20 08:54 AM
Hello, everyone. I hope you're doing well.
my work at this time: https://github.com/MarginallyClever/Daisy-Driver-2.0-firmware/commit/465ec3dbeb831ee2f49fd6a6648da8fd7377a56a
My code is written in Arduino 2.2.1 with https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json. It is an order of magnitude faster than STM32CubeIDE.
I have an STM32F405 communicating with 4 of its sister boards via CAN 1.0. When the master node boots it calls everyone to transmit their CAN IDs to enumerate the network. I get sometimes 2, sometimes 3 frames, meaning a few have been lost. From the status lights on the other devices I know they all received and replied. I never get the CAN overflow (CAN1->RF0R & CAN_RF0R_FOVR0) bit on either mailbox.
I have also tried to write an RX interrupt. This appears to halt the board - the light turns on once and all serial updates stop. (see code below)
Do you know what I'm doing wrong with the interrupt? Can you give me a hint why I'm losing frames?
Thank you!
----------------------
2023-09-20 01:03 PM
Did you check with a CAN bus analyzer to see if the other CAN nodes indeed send a reply? If not, then it could have been a bus collision and they are not set for auto retransmission so they tried to send once and aborted. Post your code for the other nodes when you initialize the CAN controller.
2023-09-25 07:43 AM - edited 2023-09-25 07:46 AM
Hi Karl,
Instead of the diff in the OP, here's a direct link to the canbus class, including initialization: https://github.com/MarginallyClever/Daisy-Driver-2.0-firmware/blob/465ec3dbeb831ee2f49fd6a6648da8fd7377a56a/daisyDriver/CANBus.ino#L187. I call this as "init(500000,2)". All the devices are initialized the same, excepting their CAN id (which is set from dip switches)
You will see https://github.com/MarginallyClever/Daisy-Driver-2.0-firmware/blob/465ec3dbeb831ee2f49fd6a6648da8fd7377a56a/daisyDriver/CANBus.ino#L239C3-L239C22 says retransmission is on for both CAN1 and CAN2.
The halting problem was first reported to me in https://github.com/nopnop2002/Arduino-STM32-CAN/issues/60 by a very experienced CAN and STM developer.
2023-09-25 07:52 AM
Make sure you don't have ANY blocking code in your Interrupt Handlers or Callbacks.
Qualify the interrupt source on entry, save reentry issues, and tail-chaining NVIC propagation delay issues.
Make sure all sources are cleared prior to departure, otherwise you'll get an interrupt storm and no lower priority or foreground execution will occur.
Make sure you don't have any errors or stalls that would preclude further reception.
I've done some CAN work on F2, F4, but it's not something I'm currently invested in.
2023-09-26 08:58 AM
All I'm doing in blinking an LED, so I'm pretty sure that's not blocking.
> Qualify the interrupt source on entry, save reentry issues, and tail-chaining NVIC propagation delay issues. Make sure all sources are cleared prior to departure, otherwise you'll get an interrupt storm and no lower priority or foreground execution will occur. Make sure you don't have any errors or stalls that would preclude further reception.
Pardon my ignorance, I don't know what any of that means. At this point I'm just blinking a light, it shouldn't halt.