cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up basic bidirectional communication over CAN using two stm32f042 nucleo boards

Lolomolo
Associate II

I am using the STM32CubeIDE.

I would like to use the standard HAL libraries to establish communication between two boards.

I looked around a decent amount for example code but all the code I have found uses either old or custom libraries incompatible with the current version of HAL.

Let me know if there is an easily accessible implementation tutorial or datasheet.

Please help me get the following functionality.

Functionality:

I want to have a button on each and be able to send a CAN message triggering the other board to toggle its on-board LED attached to PB3.

Schematic:

Two Nucleo STM32f042 boards with their PA11(CAN_TX) and PA12 (CAN_RX) cross connected.

a pullup resistor and wire attached to PB3 to be used as a makeshift button.

Best,

-Danny

4 REPLIES 4

Cross connecting them is unlikely to work. Need a diode arrangement if you're going to skip the transceiver.

Keil CAN app note, see page 4 for "tiny network"

http://www.keil.com/appnotes/files/apnt_236_v2.9.pdf

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

I omitted that i have two sn65hvd233 transceivers. Please assume the hardware setup works. I am worried exclusively about the firmware.

Thanks for the app note, looks like a good read

You'd need one board to be in reception mode, such that it pulls and acknowledges packets sent by the other. Both need a common bit rate, and a common ground. Absent a device correctly sinking the messages and acknowledging them the transmitter we report error(s).

Perhaps look at the F0 EVAL board examples in the CubeF0 trees for a worked CAN example. Apply/port to your specific context.

I'm not using F0, CAN and HAL in this context, I did post a clean working example for the SPL F4 libraries on the RedDragon407 boards, and my own T2 Terminus boards using STM32F205/F405 parts.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Lolomolo
Associate II

Just got back to this project. I was attempting to use the STM32091C_EVAL CAN_Networking example, but it uses outdated libraries and I am still failing to get it running on my end.

I am reading hte HAL CAN Generic Driver on the HAL Documention pdf

https://www.st.com/content/ccc/resource/technical/document/user_manual/2f/77/25/0f/5c/38/48/80/DM00122015.pdf/files/DM00122015.pdf/jcr:content/translations/en.DM00122015.pdf

However, it also does not use the new HAL_CAN_AddTxMessage and HAL_CAN_GetRxFifoFillLevel functions for tx and rx.

I am currently having issues setting up the send and receive buffers as well as putting on board into receive mode.

Let me know if you have advice here.

Best,

-Danny