Page 1 of 1

Need CAN explanation

Posted: Wed Apr 17, 2019 5:19 pm
by arbulgazar
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?

Re: Need CAN explanation  Topic is solved

Posted: Wed Apr 17, 2019 6:02 pm
by Giovanni
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

Re: Need CAN explanation

Posted: Thu Apr 18, 2019 2:06 pm
by arbulgazar
Thank you!

Re: Need CAN explanation

Posted: Tue Apr 30, 2019 2:45 pm
by arbulgazar
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?

Re: Need CAN explanation

Posted: Tue Apr 30, 2019 7:51 pm
by Giovanni
Hi,

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

Giovanni

Re: Need CAN explanation

Posted: Wed May 01, 2019 12:27 pm
by arbulgazar
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

Re: Need CAN explanation

Posted: Wed May 01, 2019 6:37 pm
by Giovanni
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