cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass CAN bus data to the BLE stack using the sequencer?

kumaichi
Associate III

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.

6 REPLIES 6
SofLit
ST Employee

Hello,

But STM32WB55 device has no CAN interface. How are you receiving CAN frames with it?

SofLit_0-1736936602511.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

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?

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

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.

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.

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS: Be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help/support.