cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F107 issue: Lan configuration fails if no cable is pluged

Artur1
Associate II
Posted on February 03, 2012 at 11:00

I've noticed an ugly thing while working with the stm32C10-Eval Board and Ethernet. In case the LAN cable is plugged, the PHY gets well initialized. But if no LAN cable is plugged in while the power on, the function ETH_Init(&ETH_InitStructure, PHY_ADDRESS)) returns ''0'' and the board is not ''offline''. Is there a chance to get the LAN working on a later cable plugin? The ETH_Init function is original from ST. This behavior occurs on both Phy modes RMI/MII. Do the Phy need some traffic to generate internal clock which are needed on the initialization?

Best Regards

#stm32f207 #rmii #eth_init
7 REPLIES 7
Artur1
Associate II
Posted on February 03, 2012 at 12:40

Ok, good and bad news. I've discovered that it hangs even Autonegotiation is ON.

On this place if(ETH_InitStruct->ETH_AutoNegotiation != ETH_AutoNegotiation_Disable)

in in Eth_Init function, the function hangs by checking for the PHY_Linked_Status. If no link is there the function returns an error.

But I need Autonegotiation :( And AutoMDX is also working with Autonegotiation state on.

Any Ideas how to fix? Is it possible to realize an interrupt if a cable will be plugged after the power on and than to do the autonegatiation?

PHY: DP84848

amin23
Associate II
Posted on February 08, 2012 at 08:37

the TCP/IP stack demonstration for STM32F2x7 V1.1.0 implements cable discon/con management

http://www.st.com/internet/mcu/product/250186.jsp

Artur1
Associate II
Posted on February 08, 2012 at 15:23

I've found the possibility to check for the LINK Interrupt on this PHY but would take a look on this implementation. Would you mind to tell me, where exact this was solved in this firmware?

Posted on February 08, 2012 at 16:08

I've found the possibility to check for the LINK Interrupt on this PHY but would take a look on this implementation. Would you mind to tell me, where exact this was solved in this firmware?

Per the Release_Notes.html, it is handled in stm32f2x7_eth_bsp. 1.1.0 / 07-October-2011

Main Changes

  • Remove the configuration where the STM32F2x7 outputs the 50 MHz clock needed by the PHY in RMII mode; on

    STM322xG_EVAL board you need to solder a

    50 MHz oscillator in manner to be able to use RMII mode

    . For more details, please refer to the readme provided within each application folder.

  • stm32f2x7_eth_bsp.c: add detection of Ethernet cable disconnection/connection (notification message displayed on the LCD)

/**
* @brief Configure the PHY to generate an interrupt on change of link status.
* @param PHYAddress: external PHY address
* @retval None
*/
uint32_t Eth_Link_PHYITConfig(uint16_t PHYAddress)
{
uint32_t tmpreg = 0;
/* Read MICR register */
tmpreg = ETH_ReadPHYRegister(PHYAddress, PHY_MICR);
/* Enable output interrupt events to signal via the INT pin */
tmpreg |= (uint32_t)PHY_MICR_INT_EN | PHY_MICR_INT_OE;
if(!(ETH_WritePHYRegister(PHYAddress, PHY_MICR, tmpreg)))
{
/* Return ERROR in case of write timeout */
return ETH_ERROR;
}
/* Read MISR register */
tmpreg = ETH_ReadPHYRegister(PHYAddress, PHY_MISR);
/* Enable Interrupt on change of link status */
tmpreg |= (uint32_t)PHY_MISR_LINK_INT_EN;
if(!(ETH_WritePHYRegister(PHYAddress, PHY_MISR, tmpreg)))
{
/* Return ERROR in case of write timeout */
return ETH_ERROR;
}
/* Return SUCCESS */
return ETH_SUCCESS;
}
/**
* @brief EXTI configuration for Ethernet link status.
* @param PHYAddress: external PHY address
* @retval None
*/
void Eth_Link_EXTIConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the INT (PB14) Clock */
RCC_AHB1PeriphClockCmd(ETH_LINK_GPIO_CLK, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Configure INT pin as input */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = ETH_LINK_PIN;
GPIO_Init(ETH_LINK_GPIO_PORT, &GPIO_InitStructure);
/* Connect EXTI Line to INT Pin */
SYSCFG_EXTILineConfig(ETH_LINK_EXTI_PORT_SOURCE, ETH_LINK_EXTI_PIN_SOURCE);
/* Configure EXTI line */
EXTI_InitStructure.EXTI_Line = ETH_LINK_EXTI_LINE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable and set the EXTI interrupt to the highest priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/**
* @brief This function handles Ethernet link status.
* @param None
* @retval None
*/
void Eth_Link_ITHandler(uint16_t PHYAddress)
{
/* Check whether the link interrupt has occurred or not */
if(((ETH_ReadPHYRegister(PHYAddress, PHY_MISR)) & PHY_LINK_STATUS) != 0)
{
EthLinkStatus = ~EthLinkStatus;
#ifdef USE_LCD
/* Set the LCD Text Color */
LCD_SetTextColor(Red);
if(EthLinkStatus != 0)
{
/* Display message on the LCD */
LCD_DisplayStringLine(Line5, (uint8_t*)'' Network Cable is '');
LCD_DisplayStringLine(Line6, (uint8_t*)'' unplugged '');
}
else
{
/* Display message on the LCD */
LCD_DisplayStringLine(Line5, (uint8_t*)'' Network Cable is '');
LCD_DisplayStringLine(Line6, (uint8_t*)'' now connected '');
}
#endif
}
}

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jean-philippe Rey
Associate II
Posted on November 28, 2013 at 10:08

Hi Clive1,

I am having the same problem right now with the STM32f207 & Ethernet PHY (RMII). Despite the fact the Link status callback notifies the system about the link state, the ETH_Init() function is not well suited for hotplug, as it is implemented as a blocking function. Did ST work on that recently?

I'll probably rewrite the ETH_Init() in order to allow hotplug but if ST still did it, it would save me some time...

Best regards,

Posted on November 28, 2013 at 14:07

I don't work for ST, so can't give you a specific insight there.

I would go look over the libraries in the Ethernet IAP examples for the F2 and F4 series, and see if anything has been resolved.

Remember the examples are pitched as demonstrations, and are simplified, additional effort will be required to understand them, test them, and get them in a state suitable for commercial application.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jean-philippe Rey
Associate II
Posted on November 28, 2013 at 15:02

You're right, I'll expect to resolve the hotplug issue by myself.

By the way, (with more than 7000 posts, you seem to be an expert), may you know how to differentiate a valid response to a ''read request'' over the SMI bus (from MAC to PHY) from a ''no answer'' response?

For example, if you want to read register 0x01 (basic status register) of the PHY, the latter will respond with a 16bit value, equal to the BSR.

Now imagine the PHY is not responding, as the DATA line is shared (open-collector, pull-up), the MAC could believe that the PHY just answered 0xFFFF because it corresponds to a ''always released DATA line'' value.

I know that in the SMI frame, a Turn-Around time is specified between the Reg_addr and the Data_field and in case of a READ request the PHY should assert the DATA line during this period, but in the stm32f2x7_eth.c source, the ETH_ReadPHYRegister() method doesn't seem to check that PHY is doing so.

Best regards,