CAN communication using STM32F4-Disc's external header

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

jslee
Posts: 3
Joined: Thu Jun 11, 2020 9:54 am

CAN communication using STM32F4-Disc's external header

Postby jslee » Mon Apr 05, 2021 8:05 am

Hi, I'm studying can communication.
I have STM32F4-Disc Board and did loopback test using files in 'testhal/STM32/CAN/*'. Checked LED blink, changed led
Now, I want to test using STM32F4-Disc's external header
Is there a test code about that? or reference homepage?
ChibiOS is hard to me, and I'm trying continue.

Below is thing I checked

In the datasheet,
CAN1_RX : PA11 / PB8 / PD0
CAN1_TX : PA12 / PB9 / PD0
(1) can't use PA11,12 cause the pins are used for OTG
(2) I'm testing PB8, 9 pins

User avatar
Giovanni
Site Admin
Posts: 13427
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 835 times
Been thanked: 730 times
Contact:

Re: CAN communication using STM32F4-Disc's external header

Postby Giovanni » Mon Apr 05, 2021 8:12 am

Hi,

The F4 discovery board does not have CAN drivers, how are you planning to connect it?

You should get a board with CAN drivers and use that for your experimentation.

Giovanni

jslee
Posts: 3
Joined: Thu Jun 11, 2020 9:54 am

Re: CAN communication using STM32F4-Disc's external header

Postby jslee » Mon Apr 05, 2021 9:48 am

Thank you for reply Giovanni.

My target is to use CAN interface on F4 discovery board.
(found '2*CAN interface', in STM32F407 datasheet)
I have found that I need transceiver for CAN communication.
So, I planned test environment like below.

┌─── [transceiver_1] ─ (2) ─ [F4 Board_1]
│ (1)
└─── [transceiver_2] ─ (3) ─ [F4 Board_2]
* connections :
(1)
    transceiver_1's CAN_H ↔ transceiver_2's CAN_H
    transceiver_1's CAN_L ↔ transceiver_2's CAN_L
(2)
    F4 Board_1's PB8(CAN1_RX) ↔ transceiver_1's RX
    F4 Board_1's PB9(CAN1_TX) ↔ transceiver_1's TX
(3)
    F4 Board_2's PB8(CAN1_RX) ↔ transceiver_2's RX
    F4 Board_2's PB9(CAN1_TX) ↔ transceiver_2's TX
*MY material :
    F4 Board * 2
    transceiver * 2(CJMCU-2551*2 or WCMCU-230*2)
    120Ω resistor, cables

Can I test CAN communication in this situation?

User avatar
Giovanni
Site Admin
Posts: 13427
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 835 times
Been thanked: 730 times
Contact:

Re: CAN communication using STM32F4-Disc's external header

Postby Giovanni » Mon Apr 05, 2021 10:39 am

Yes, keep wiring short and be careful to program GPIOs for CAN.

In the CAN demo you need to remove the loopback option from the configuration structure and it should work almost as-is. Note the all configurations come straight from the STM32 Reference Manual, make sure to read about the settings in the various registers.

Giovanni

jslee
Posts: 3
Joined: Thu Jun 11, 2020 9:54 am

Re: CAN communication using STM32F4-Disc's external header

Postby jslee » Mon Apr 05, 2021 11:32 am

Alright, Thank you.
I'll test with your advice and reply good result.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 5 guests