Page 1 of 1

STM32F4 Pin-Remap

Posted: Fri Nov 15, 2013 6:41 pm
by tobi
Hi,
I am an IT student and evaluating ChibiOS for a project.
We are using ChibiOS in version 2.6.1 and developing on the new STM32F429i DISCOVERY board.

We want to set up a little test with the Can-Hal and have some questions I don’t really find in the documentation.
We want to use PD0 and PD1 for the CAN1 on the board and now we have to remap this pins.

Solution(from other posts):
1) Configure the pins 0 and 1 from Port D in the board.h VAL_GPIOD_* ...
2) Remap the pins, so the OS knows what for pins CAND1 is using

Questions:
1) Is there any document related to remapping?
2) There was an additional configuration shown in a thread viewtopic.php?f=16&t=1307:
#define VAL_GPIODCRL 0x34B334B8 //0x34B33444 value before change
3) The code block about remapping can from the thread above was for the stm32f10x.h and we are using stm32f4xx.h .
The shown code is:
AFIO->MAPR|= AFIO_MAPR_CAN_REMAP_REMAP3;
And in the stm32f4xx.h file is nothing about AFIO_BASE, the AFIO_TypeDef or pin selection for the HAL driver.
Was it just a gimmick for the f10 and we have to do it manual?

regards
Tobias

Re: STM32F4 Pin-Remap

Posted: Fri Nov 15, 2013 8:13 pm
by Giovanni
Hi,

The STM32F4 (and all others except F1) do not have AFIO anymore, each pin can be reconfigured in up to 16 different alternate functions. The table of the alternate functions is present in the DataSheet (note, not the Reference Manual).

You have to identify other pins that are CAN-capable then using the function palSetPadMode() it is possible to change the alternate function of pins.

Giovanni

Re: STM32F4 Pin-Remap

Posted: Fri Nov 15, 2013 8:24 pm
by Tectu
Giovanni wrote:The STM32F4 (and all others except F1) do not have AFIO anymore, each pin can be reconfigured in up to 16 different alternate functions.

Something went wrong here, no? They do have AFIO instead of remapping.


~ Tectu

Re: STM32F4 Pin-Remap

Posted: Fri Nov 15, 2013 8:37 pm
by Giovanni
You are wrong, AFIO is only present in F1 devices, newer STM32s have only GPIO.

giovanni

Re: STM32F4 Pin-Remap

Posted: Sat Nov 16, 2013 12:24 am
by Tectu
But doesn't AFIO stand for AternateFunctionInputOutput? That's the system that all (except the F1) use?


~ Tectu

Re: STM32F4 Pin-Remap

Posted: Sat Nov 16, 2013 1:34 am
by tobi
Ok we want to use PD0 for CAN_RX and PD1 for CAN_TX
STM32F49 Datasheet shows us its AF9 for PD0 and PD1....

The code would look like that right?
palSetPadMode(GPIOD, 0, PAL_MODE_ALTERNATE(9));
palSetPadMode(GPIOD, 1, PAL_MODE_ALTERNATE(9));

Do we have to set the speed and mode of the pin in addition? And when how?

Re: STM32F4 Pin-Remap

Posted: Sat Nov 16, 2013 1:13 pm
by Giovanni
Hi,

You can OR the options to PAL_MODE_ALTERNATE(9), for example : PAL_MODE_ALTERNATE(9) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_OTYPE_OPENDRAIN.

See all the definitions in the PAL driver (.\os\hal\platforms\STM32\GPIOv2\pal_lld.h).

Giovanni

Re: STM32F4 Pin-Remap

Posted: Sat Nov 16, 2013 1:21 pm
by Giovanni
Tectu wrote:But doesn't AFIO stand for AternateFunctionInputOutput? That's the system that all (except the F1) use?


Just read the code he posted, he is referring to the AFIO unit, there is no such a thing anymore.

Giovanni