Need CAN explanation Topic is solved

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: barthess, RoccoMarco, utzig, lbednarz, tfAteba

User avatar
arbulgazar
Posts: 8
Joined: Sun Dec 16, 2018 5:12 pm
Has thanked: 1 time

Need CAN explanation

Postby arbulgazar » Wed Apr 17, 2019 5:19 pm

Greetings, I am new to the whole CAN thing and am trying to use it for my STM32F407 Discovery board project. I am looking at testhal\STM32\STM32F4xx\CAN example project and can't understand how to figure out and set-up exact pins that CAN driver will be using. From my board's datasheet I see that there are alternative options available in terms of CAN pinout (PA11 & PA12 vs PD0 & PD1 for example). How do I select one of them to be used by driver? Do I just modify alternate functions for pins of interest in the board.h?

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

Re: Need CAN explanation  Topic is solved

Postby Giovanni » Wed Apr 17, 2019 6:02 pm

Hi,

Correct, if you use ChibiStudio you need to generate a new board.h starting from the .chcfg file (it is an XML description of pin settings), you may copy the board directory into your project and customize it.

If you don't use ChibiStudio then you can edit board.h directly, again, it is better to create board files into the project.

Search on playembedded.org for info, there are tutorials covering this.

Giovanni

User avatar
arbulgazar
Posts: 8
Joined: Sun Dec 16, 2018 5:12 pm
Has thanked: 1 time

Re: Need CAN explanation

Postby arbulgazar » Thu Apr 18, 2019 2:06 pm

Thank you!

User avatar
arbulgazar
Posts: 8
Joined: Sun Dec 16, 2018 5:12 pm
Has thanked: 1 time

Re: Need CAN explanation

Postby arbulgazar » Tue Apr 30, 2019 2:45 pm

Sorry for raising this topic again, but I can't figure out how to work with the driver. I configured the board using the .chcfg file to use GPIOB8 as CAN1_RX and GPIOB9 as CAN1_TX (Alternate mode, alternate function 9 as in datasheet) for 2 boards that I have. I am trying to make 2 STM boards communicate, and connected those with 2 jump-wires PB9 to PB8, PB8 to PB9 respectfully.
Now on one board, I disabled TX thread, but the RX thread led is not blinking, so it's not receiving the message I assume. And removed loop back mode from both configurations. Is there something I am missing in driver configuration to make it work with the pins I assigned?

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

Re: Need CAN explanation

Postby Giovanni » Tue Apr 30, 2019 7:51 pm

Hi,

How do you connect the boards? do you have CAN transceivers? are those GPIOs available on the board?

Giovanni

User avatar
arbulgazar
Posts: 8
Joined: Sun Dec 16, 2018 5:12 pm
Has thanked: 1 time

Re: Need CAN explanation

Postby arbulgazar » Wed May 01, 2019 12:27 pm

Hello Giovanni,

Thanks for the help!
GPIOs are available on the board, however, I do not have transceivers yet, figured it out already. I thought that if board supports CAN - they are built-in in the board. But reading board specification more carefully, it's said that I need the transceivers, so that is the problem.
For learning purposes though - how driver figures out which pins to use? Board-specific configuration makes sure it is sending the signal to all eligible GPIOs?

Kind regards,
Max

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

Re: Need CAN explanation

Postby Giovanni » Wed May 01, 2019 6:37 pm

Hi,

In our HAL drivers are not aware of GPIO settings, those are left to the application using the PAL API or board files.

Rationale is: GPIO assignments change from device to device, we don't want to bring that complexity into each and every driver.

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 1 guest