2025-01-13 04:49 PM - last edited on 2025-01-15 02:27 AM by Andrew Neil
Hello, I have a STM32WB55RE connected to a CAN bus. I'm receiving the CAN data via the Main function using polling. When a message is received (250K Baud Rate) I want to forward that data to the BLE stack so I can send it to another STM32WB55RE. I'm currently using the sequencer to manage all the BLE tasks. There doesn't seem to be any queue or semaphore that I can use with the sequencer.
Is there a preferred method to CAN bus data from the Main loop to a task running within the sequencer?
Kindest regards.
Solved! Go to Solution.
2025-01-15 06:28 AM
Handshaking mechanism is important for such data handling involving the synchronization between producer/consumer. That's why multiple/circular buffering is suitable for such case even by using Tasks because there is a difference in the throughput between the interfaces.
See an example of Circular buffer implementation.
2025-01-15 02:23 AM
Hello,
But STM32WB55 device has no CAN interface. How are you receiving CAN frames with it?
2025-01-15 02:26 AM - edited 2025-01-15 02:28 AM
Why would it make any difference that the data came from CAN?
As far as the BLE stack is concerned, surely, it's just data - the interface over which it arrived is irrelevant?
2025-01-15 05:23 AM
Hello,
Thank you for your response. The CAN bus data is being collected via a MCP2515-I/ML and MCP2562T-E_MF. I'm receiving the CAN bus data correctly. Just can't figure out the best way to transfer that data to the BLE stack to be sent. I'm using the default sequencer from the P2P_Server/Client applications.
Kindest regards
2025-01-15 05:38 AM - edited 2025-01-15 05:43 AM
Hello,
Now it's clear.
MCP2515: CAN controller over SPI.
MCP2562: is the CAN transceiver.
So your question is about MCP2515 SPI throughput versus the Bluetooth. The interface having the less throughput will be the bottleneck + How CPU will be able to handle that transfer based on that throughput (maybe using DMA?). I'm not expert of wireless but I think what you need to care of, is to manage the double/multiple buffering data transfer between SPI and Bluetooth.
2025-01-15 06:17 AM
Hello,
I'm initially just trying to get the data over to the Bluetooth stack. I was thinking a queue would suit my purposes, but the sequencer doesn't have any queuing mechanism. I could use a global variable to pass the data but that's troublesome because even though 250kb isn't the fastest bus, eventually the global variable will become read/write locked at some point. I thought of creating a task in the sequencer to poll the CAN bus, maybe that will work?
I'm basically just trying to figure out what is the recommended method for getting data running in the main application passed over to the Bluetooth stack so it can be transmitted.
Thank you.
2025-01-15 06:28 AM
Handshaking mechanism is important for such data handling involving the synchronization between producer/consumer. That's why multiple/circular buffering is suitable for such case even by using Tasks because there is a difference in the throughput between the interfaces.
See an example of Circular buffer implementation.
2025-01-15 06:41 AM
Thank you, I will investigate using a circular buffer. Thank you for your help!