Testing CAN Bus on STM32F4Discovery board

377 views
Skip to first unread message

Alan Carvalho de Assis

unread,
Jun 9, 2018, 11:36:40 AM6/9/18
to Sebastien Lorquet, NuttX
Hi Sebastien,

How are you?

I recall you tested the CAN Bus peripheral support on STM32 boards.

Today I am testing the NuttX CAN Bus support on STM32F4Discovery
board, but without success...

I enabled the CAN1 peripheral, enabled the CAN Driver and keep the
default configuration to use Standard IDs:

--- CAN Driver Support
[ ] CAN extended IDs
[ ] CAN FD
(8) CAN driver I/O buffer size
(4) Number of pending RTRs
[ ] can_txready interface
[ ] CAN loopback mode

Then I enabled the CAN Example:

[*] CAN example
(/dev/can0) Device Path
(32) Number of Messages
Read-only, write-only or read-write (Write-only) --->

Initially I connected two SN65HVD230 transceivers
(https://www.aliexpress.com/item/SN65HVD230-CAN-Board-Network-Transceiver-Evaluation-Development-Module/32713387496.html)
on two STM32F4Discovery boards. The first board was write-only and the
second board as read-only.

But running the "can" application on nsh> of each board didn't show
any communication. It only inform that the TX message was generated on
one board, but nothing appears on the other board.

Then I decided to look the CAN TX (PD1 pin of stm32f4discovery board)
but it doesn't look like a CAN valid frame, please see attached
images.

I can see 15 "pulses" in the CAN TX pin, but nothing else. Do you
think the CAN support is broken?

In the past I tested the NuttX CAN Bus support using the MCP2515
driver that I created, but this time I decided to test the CAN
Peripheral existent on STM32 and to my surprise it is not working.

Do you have some suggestion?

BR,

Alan
stm32f4discovery_can_test.png
stm32_can_test2.png
stm32_can_test3.png
stm32_can_test4.png

Sebastien Lorquet

unread,
Jun 9, 2018, 3:12:00 PM6/9/18
to Alan Carvalho de Assis, Sebastien Lorquet, NuttX
Hello

Did you install termination resistors on the bus? I noticed that CAN
does not work AT ALL without that (error counters overflow very fast and
then communication stops). Also make sure that the ground is well
connected between the two boards, CAN is not as tolerant as RS485 for that.

Sorry if your problem is more complex, but bus electrical state was a
major source of problems until I understood that, and afterwards I did
not get any other communication issue.

Note that I did my tests on STM32L4, but the driver was just copied from
STM32F4, and it worked well.

Sebastien

Alan Carvalho de Assis

unread,
Jun 9, 2018, 6:40:18 PM6/9/18
to Sebastien Lorquet, NuttX
Thank you Sebastien!

Yes, it has 120R termination resistor at each end and I connected the
ground as well.

I will try an older version just to double check.

BR,

Alan
Reply all
Reply to author
Forward
0 new messages