2017-08-03 10:15 AM
Hello,
I currently have the LWIP example from the STM32CubeF7code samples running on an STM32F746 Nucleo Board. I would like to change some of the pin assignments to test the code on a prototype board the uses the 746 MCU. So far I have tried using the GPIO_AF11_ETH command in the initialization to change RMII_MII_TXD0 from PG13 to PB12. Is there a better way to do this? Thank you!
#ethernet-stm32f7 #stm32f746-nucleo #stm32 #stm32cube_fw_f7_v1.7.02017-08-03 10:23 AM
The example code is manually generated, not via CubeMX, so you'll need to go into the BSP layers and change clocks and pins as required to migrate functionality to different boards.
2017-08-03 01:06 PM
Thank you! This is what I was looking for, The two processors are the same and the have the same pinout and clock configurations for the most part, the only issue is switching the pins from PG13 to PG12. Would you happen to know which BSP layer holds the Ethernet pin assignments? I can't seem to find the correct file. Thank you for your quick response!
2017-08-03 02:09 PM
Grep or find-in-files HAL_GPIO_Init, I don't have the F7 library installed on this box.
2017-08-03 06:22 PM
They're not in the board support. They're in the LwIP Applications example, file ethernetif.c
from STM32Cube/Repository/STM32Cube_FW_F7_V1.7.0/Projects/STM32F746ZG-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src/ethernetif.c :
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
{ GPIO_InitTypeDef GPIO_InitStructure; /* Enable GPIOs clocks */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE();/* Ethernet pins configuration ************************************************/
/* RMII_REF_CLK ----------------------> PA1 RMII_MDIO -------------------------> PA2 RMII_MDC --------------------------> PC1 RMII_MII_CRS_DV -------------------> PA7 RMII_MII_RXD0 ---------------------> PC4 RMII_MII_RXD1 ---------------------> PC5 RMII_MII_RXER ---------------------> PG2 RMII_MII_TX_EN --------------------> PG11 RMII_MII_TXD0 ---------------------> PG13 RMII_MII_TXD1 ---------------------> PB13 *//* Configure PA1, PA2 and PA7 */
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Alternate = GPIO_AF11_ETH; GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure PB13 */ GPIO_InitStructure.Pin = GPIO_PIN_13; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configure PC1, PC4 and PC5 */ GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);/* Configure PG2, PG11, PG13 and PG14 */
GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_11 | GPIO_PIN_13; HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); /* Enable the Ethernet global Interrupt */ HAL_NVIC_SetPriority(ETH_IRQn, 0x7, 0); HAL_NVIC_EnableIRQ(ETH_IRQn); /* Enable ETHERNET clock */ __HAL_RCC_ETH_CLK_ENABLE();}2017-08-04 09:45 AM
In that case would I have to make the following pin changes in order to use PB12 instead of PG13 for
RMII_MII_TXD0:
/* Configure PA1, PA2 and PA7 */ GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Alternate = GPIO_AF11_ETH; GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); /*Configure PB12 to be used in alternate function mode AF11GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Alternate = GPIO_AF11_ETH; GPIO_InitStructure.Pin = GPIO_PIN_12; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configure PB13 */ GPIO_InitStructure.Pin = GPIO_PIN_13 ; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configure PC1, PC4 and PC5 */ GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);/* Configure PG2, PG11,
PG13
and PG14 */ ( remove PG13 from this list as it is being replaced by PB12) GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_11| GPIO_PIN_13
; HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);