cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H750XBHX - CANFD Callback problem

sqwerize
Associate III

Hey, I have a problem with the callback for FDCAN1. I am sending frames through ucandevices converter but the callback for FIFO0 is not called. The frames are definitely arriving, I added a test FreeRTOS and a task to receive and send frames to CAN1 and it worked very well, frames were received and sent back to the bus.
I have NVIC interrupts set up, I fiddled with the clock for CANFD and speeds, also with no effect.

Is anyone able to help me?
I am sending my project as an attachment

16 REPLIES 16

If i remember your clock was 24MHz so these are the settings for 500/kbs

KarlYamashita_0-1713460293810.png

 

 

If you find my answers useful, click the accept button so that way others can see the solution.

sqwerize_0-1713460954642.png

sqwerize_1-1713460990371.pngsqwerize_2-1713461063532.png

I changed the clock but I don't know if I did it right.... And should the Clock for FDCAN be set to HSE?

1000017324.png

If you find my answers useful, click the accept button so that way others can see the solution.

THANK YOU VERY MUCH !! By the way, can you tell me what this tool is? 

sqwerize
Associate III

@SofLit @Karl Yamashita 
I seem to have enjoyed the normal functioning of the project too soon....
The bridge communication works partially for me. I send frames from one UCCB converter with a baudrate of 500kB/s, the stm32 receives these frames on CAN1 and sends them on CAN2. I have a second UCCB converter that receives these frames correctly and I can see them. The problem arises when I want to send the frames the other way, that is, when I send the frames to CAN2 the callback is not called and the frames are not sent to CAN1 on the STM32 controller. In addition, when I want to configure filters in the MX_FDCAN2_Init method, all communication goes down and sending from CAN1 to CAN2 stops working and I am left with nothing....

Offhand I don't know why you're not getting an interrupt on FDCAN2?

 

But as for your bridging attempt. It's really called a gateway. Not sure what your end product is going to be?

 

I've designed a ton of interfaces that act as a gateway for different make of vehicles. I can trick the head unit into thinking that the car is in reverse buy overriding the DRIVE parameter with a REVERSE parameter so that we can feed video into the display or change to PARK parameter to allow inputting navigation destination while driving. I can trick the Radio into thinking that the Sirius radio is playing and feed a Bluetooth audio into the head unit using the same audio input using a Bluetooth audio module. This was before head units had Bluetooth capabilities. So basically you intercept the CAN message, change certain parameters and then pass it through.

 

The best practice is to do all your processing outside of the interrupt. You should actually make a ring buffer to hold several CAN messages to parse in your main while loop. In your main while loop you can check to see if you have a new message on either FDCAN1 or FDCAN2. You can then pass that message to the opposite FDCANx or modify the data and pass it through. 

 

If you find my answers useful, click the accept button so that way others can see the solution.

@Karl Yamashita  Thanks for the suggestion, I was afraid to implement the "gateway" in the while loop as you mentioned, to avoid delays in transmitting frames. I read that the best practice is to use DMA for CAN, but STM32 doesn't have this functionality... so I decided to go with interrupts, though I'm concerned about the processor load. The project is intended to act as a gateway for activating the laser in BMW G30 lamps with matrix LED functionality. The LCI versions received two lenses with matrix diodes and a separate laser section that turns using a stepper motor in the lamps. My project works great on my laptop, on which I wrote a program that acts as a gateway and modifies certain frames and sends them back to the lamps. Additionally, I already have a ready solution for matrix lamps without a laser, which is already in use in several cars. However, for the lights with lasers, I needed a more powerful processor, and as you can see, I've been struggling with it for a few days now.

So, you suggest to implement the "gateway" in the main loop? Additionally, my adapter needs to perform a few other tasks, and the best solution for this was FreeRTOS, as I needed to perform other background tasks like leveling the laser, sending turn signals based on a 12v signal on a wire, etc. You might ask why I need to do this, so here's the answer. BMW G30 versions from 2017 to 07/2020 do not support these lamps because the BDC is of an older generation; in the LCI version, they introduced the new BDC3, which supports these lamps.

Here is adapter for standard matrix led headlights: https://www.tiktok.com/@sqwerize/video/7343750983870172449?is_from_webapp=1&sender_device=pc&web_id=7325035726109853217

Here is laser:
https://www.tiktok.com/@sqwerize/video/7358763883491790113?is_from_webapp=1&sender_device=pc&web_id=7325035726109853217