Page 1 of 1

CAN communication using STM32F4-Disc's external header

Posted: Mon Apr 05, 2021 8:05 am
by jslee
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

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

Posted: Mon Apr 05, 2021 8:12 am
by Giovanni
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

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

Posted: Mon Apr 05, 2021 9:48 am
by jslee
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?

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

Posted: Mon Apr 05, 2021 10:39 am
by Giovanni
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

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

Posted: Mon Apr 05, 2021 11:32 am
by jslee
Alright, Thank you.
I'll test with your advice and reply good result.