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
STM32F4 Pin-Remap
Moderator: RoccoMarco
- 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
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
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
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
- 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
You are wrong, AFIO is only present in F1 devices, newer STM32s have only GPIO.
giovanni
giovanni
Re: STM32F4 Pin-Remap
But doesn't AFIO stand for AternateFunctionInputOutput? That's the system that all (except the F1) use?
~ Tectu
~ Tectu
Re: STM32F4 Pin-Remap
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?
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?
- 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
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
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
- 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
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