2021-03-18 11:24 AM
Hello everyone, i am new to approaching st boards.
My goal is to create a Can BUS communication between two stm32f407 discovery boards (normal mode).
I initially approached can using the loopback mode example.
Now I wanted to move on to the next step by having the two cards talk to each other.
I tried to modify my loopback program but I think I missed some details.
I have to create a program for the card that receives and a program for the one that transmits and then have both received and transmitted.
To send the txData messages in the mailbox I would like to use a button.
At the end of this I would like to turn on a led in the Rx card to confirm receipt of the message.
I need someone to answer me in a simple and effective way to these points:
-Which parameters are to be set regarding the bit timing? (Prescaler, time quanta, seg1, seg2, ....)
Do they have to be the same for both cards in order to synchronize?
-What are the functions to be written for the two programs Tx and Rx in chronological order and above all in which parts of the program are they written?
for example: 1) HAL_CAN_Start (& hcan1)
while { 2) HAL_CAN_GetTxMailboxesFreeLevel (& hcan1)
3) (HAL_CAN_AddTxMessage(& hcan1)
}
- Which filters are to be set? (I suppose I will have to set them all to zero to receive all the messages I want to transmit)
I would also like to ask if there were already two programs, one Tx and one Rx that could be loaded into the boards in order to carry out communication.
Thanks so much
2021-03-18 11:48 AM
>>Which parameters are to be set regarding the bit timing? (Prescaler, time quanta, seg1, seg2, ....) Do they have to be the same for both cards in order to synchronize?
Well, Yes, that's how this stuff works.
You'd need transceivers at either end, or use the diode method Keil has in their app notes.
Keil CAN app note googled -> https://www.keil.com/appnotes/docs/apnt_236.asp
>>Which filters are to be set? (I suppose I will have to set them all to zero to receive all the messages I want to transmit)
Start with a broad one that accepts everything
I've posted worked examples of both ends in the past. Perhaps look in the CubeF4 example directories for boards having CAN transceivers, ie the EVAL ones. And port those
2021-03-18 01:42 PM
Sorry for not entering the other details.
For both cards I use a mcp2562 transceiver and both nodes are terminated with a 120ohm resistor.
So there are no ideal parameters for bit timing? Thanks for the quick response
2021-03-18 02:34 PM
Usually a matter of what fits, you want 500 kbps or 1 Mbps ?
The math isn't exactly complicated.
STM32Cube_FW_F4_V1.24.1\Projects\STM324xG_EVAL\Examples\CAN\CAN_Networking\readme.txt
2021-03-18 10:59 PM
Hi,
Please see this post: https://community.st.com/s/question/0D53W00000cwGTH/stm32f407vet-can-bus-interrupt-does-not-trigger
Best Regards,
Slawek