STM32F4 Pin-Remap

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

Moderator: RoccoMarco

Post Reply
tobi
Posts: 2
Joined: Fri Nov 15, 2013 6:02 pm

STM32F4 Pin-Remap

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 Pin-Remap

Post 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
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: STM32F4 Pin-Remap

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 Pin-Remap

Post by Giovanni »

You are wrong, AFIO is only present in F1 devices, newer STM32s have only GPIO.

giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: STM32F4 Pin-Remap

Post by Tectu »

But doesn't AFIO stand for AternateFunctionInputOutput? That's the system that all (except the F1) use?


~ Tectu
tobi
Posts: 2
Joined: Fri Nov 15, 2013 6:02 pm

Re: STM32F4 Pin-Remap

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 Pin-Remap

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 Pin-Remap

Post 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
Post Reply