cancel
Showing results for 
Search instead for 
Did you mean: 

Support for Ethernet communication on the NUCLEO F767ZI

Anthony  Mwila
Associate II
Posted on September 13, 2017 at 01:46

Hi , I'm new to STM23 and I'm currently trying to setup Ethernet communication on the NUCLEO F767ZI. Cube Mx provides great guidance but I can't seem to find any information on how to configure the initial  ETH_HandleTypeDef structure in my Ethernet setup code . Is there any documentation or working example available that I can use to figure this out ?

#ethernet #nucleo-f767zi
1 ACCEPTED SOLUTION

Accepted Solutions
T J
Lead
Posted on September 13, 2017 at 03:16

I used the Oryx TCP folder only, part of CycloneTCP Open.

in stm32f7xx_hal_eth.h

/**
 * @brief ETH Handle Structure definition 
 */
 
typedef struct
{
 ETH_TypeDef *Instance; /*!< Register base address */
 ETH_InitTypeDef Init; /*!< Ethernet Init Configuration */
 uint32_t LinkStatus; /*!< Ethernet link status */
 ETH_DMADescTypeDef *RxDesc; /*!< Rx descriptor to Get */
 ETH_DMADescTypeDef *TxDesc; /*!< Tx descriptor to Set */
 ETH_DMARxFrameInfos RxFrameInfos; /*!< last Rx frame infos */
 __IO HAL_ETH_StateTypeDef State; /*!< ETH communication state */
 HAL_LockTypeDef Lock; /*!< ETH Lock */
} ETH_HandleTypeDef;�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

in stm32f7xx_it.c

///**
//* @brief This function handles Ethernet global interrupt.
//*/
//void ETH_IRQHandler(void)
//{
// /* USER CODE BEGIN ETH_IRQn 0 */
////////////////////
// /* USER CODE END ETH_IRQn 0 */
// HAL_ETH_IRQHandler(&heth);
// /* USER CODE BEGIN ETH_IRQn 1 */
////////////////////
// /* USER CODE END ETH_IRQn 1 */
//}�?�?�?�?�?�?�?�?�?�?�?�?�?

in main.c

extern ETH_HandleTypeDef heth;
/* ETH init function */
static void MX_ETH_Init(void)
{
 uint8_t MACAddr[6] ;
 heth.Instance = ETH;
 heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_DISABLE;
 heth.Init.Speed = ETH_SPEED_100M;
 heth.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
 heth.Init.PhyAddress = PHY_USER_NAME_PHY_ADDRESS;
 MACAddr[0] = 0x02;
 MACAddr[1] = 0x80;
 MACAddr[2] = 0xE1;
 MACAddr[3] = 0x12;
 MACAddr[4] = 0x65;
 MACAddr[5] = 0x98;
 heth.Init.MACAddr = &MACAddr[0];
 heth.Init.RxMode = ETH_RXINTERRUPT_MODE;
 heth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
 heth.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII;
 /* USER CODE BEGIN MACADDRESS */
 
 /* USER CODE END MACADDRESS */
 if (HAL_ETH_Init(&heth) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

in stm32f7xx_eth.c

/**
 * @brief STM32F746/756 Ethernet MAC interrupt service routine
 **/
void ETH_IRQHandler(void)
{
 bool_t flag;
 uint32_t status;
 //Enter interrupt service routine
 osEnterIsr();
 //This flag will be set if a higher priority task must be woken
 flag = FALSE;
 //Read DMA status register
 status = ETH->DMASR;
 //A packet has been transmitted?
 if(status & ETH_DMASR_TS)
 {
 //Clear TS interrupt flag
 ETH->DMASR = ETH_DMASR_TS;
 //Check whether the TX buffer is available for writing
 if(!(txCurDmaDesc->tdes0 & ETH_TDES0_OWN))
 {
 //Notify the TCP/IP stack that the transmitter is ready to send
 flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
 }
 }
 //A packet has been received?
 if(status & ETH_DMASR_RS)
 {
 //Disable RIE interrupt
 ETH->DMAIER &= ~ETH_DMAIER_RIE;
 //Set event flag
 nicDriverInterface->nicEvent = TRUE;
 //Notify the TCP/IP stack of the event
 flag |= osSetEventFromIsr(&netEvent);
 }
 //Clear NIS interrupt flag
 ETH->DMASR = ETH_DMASR_NIS;
 //Leave interrupt service routine
 osExitIsr(flag);
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

initialization in main::

 
int main(void) 
{
 /* USER CODE BEGIN 1 */
 
 //Initialize kernel
 osInitKernel();
 /* USER CODE END 1 */
 /* MCU Configuration----------------------------------------------------------*/
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 /* USER CODE BEGIN Init */
 /* USER CODE END Init */
 /* Configure the system clock */
 SystemClock_Config();
 /* USER CODE BEGIN SysInit */
 /* USER CODE END SysInit */
 /* Initialize all configured peripherals */
 MX_TIM4_Init();
 //MX_ETH_Init();
 MX_DAC_Init();
 MX_TIM7_Init();
 /* USER CODE BEGIN 2 */
 
 
 InitProcessor();
 Clear_ETH_nReset_Pin();
 wait_ms(1);
 Set_ETH_nReset_Pin();
 wait_ms(1);
 MX_ETH_Init();
 
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

View solution in original post

1 REPLY 1
T J
Lead
Posted on September 13, 2017 at 03:16

I used the Oryx TCP folder only, part of CycloneTCP Open.

in stm32f7xx_hal_eth.h

/**
 * @brief ETH Handle Structure definition 
 */
 
typedef struct
{
 ETH_TypeDef *Instance; /*!< Register base address */
 ETH_InitTypeDef Init; /*!< Ethernet Init Configuration */
 uint32_t LinkStatus; /*!< Ethernet link status */
 ETH_DMADescTypeDef *RxDesc; /*!< Rx descriptor to Get */
 ETH_DMADescTypeDef *TxDesc; /*!< Tx descriptor to Set */
 ETH_DMARxFrameInfos RxFrameInfos; /*!< last Rx frame infos */
 __IO HAL_ETH_StateTypeDef State; /*!< ETH communication state */
 HAL_LockTypeDef Lock; /*!< ETH Lock */
} ETH_HandleTypeDef;�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

in stm32f7xx_it.c

///**
//* @brief This function handles Ethernet global interrupt.
//*/
//void ETH_IRQHandler(void)
//{
// /* USER CODE BEGIN ETH_IRQn 0 */
////////////////////
// /* USER CODE END ETH_IRQn 0 */
// HAL_ETH_IRQHandler(&heth);
// /* USER CODE BEGIN ETH_IRQn 1 */
////////////////////
// /* USER CODE END ETH_IRQn 1 */
//}�?�?�?�?�?�?�?�?�?�?�?�?�?

in main.c

extern ETH_HandleTypeDef heth;
/* ETH init function */
static void MX_ETH_Init(void)
{
 uint8_t MACAddr[6] ;
 heth.Instance = ETH;
 heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_DISABLE;
 heth.Init.Speed = ETH_SPEED_100M;
 heth.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
 heth.Init.PhyAddress = PHY_USER_NAME_PHY_ADDRESS;
 MACAddr[0] = 0x02;
 MACAddr[1] = 0x80;
 MACAddr[2] = 0xE1;
 MACAddr[3] = 0x12;
 MACAddr[4] = 0x65;
 MACAddr[5] = 0x98;
 heth.Init.MACAddr = &MACAddr[0];
 heth.Init.RxMode = ETH_RXINTERRUPT_MODE;
 heth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
 heth.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII;
 /* USER CODE BEGIN MACADDRESS */
 
 /* USER CODE END MACADDRESS */
 if (HAL_ETH_Init(&heth) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

in stm32f7xx_eth.c

/**
 * @brief STM32F746/756 Ethernet MAC interrupt service routine
 **/
void ETH_IRQHandler(void)
{
 bool_t flag;
 uint32_t status;
 //Enter interrupt service routine
 osEnterIsr();
 //This flag will be set if a higher priority task must be woken
 flag = FALSE;
 //Read DMA status register
 status = ETH->DMASR;
 //A packet has been transmitted?
 if(status & ETH_DMASR_TS)
 {
 //Clear TS interrupt flag
 ETH->DMASR = ETH_DMASR_TS;
 //Check whether the TX buffer is available for writing
 if(!(txCurDmaDesc->tdes0 & ETH_TDES0_OWN))
 {
 //Notify the TCP/IP stack that the transmitter is ready to send
 flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
 }
 }
 //A packet has been received?
 if(status & ETH_DMASR_RS)
 {
 //Disable RIE interrupt
 ETH->DMAIER &= ~ETH_DMAIER_RIE;
 //Set event flag
 nicDriverInterface->nicEvent = TRUE;
 //Notify the TCP/IP stack of the event
 flag |= osSetEventFromIsr(&netEvent);
 }
 //Clear NIS interrupt flag
 ETH->DMASR = ETH_DMASR_NIS;
 //Leave interrupt service routine
 osExitIsr(flag);
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

initialization in main::

 
int main(void) 
{
 /* USER CODE BEGIN 1 */
 
 //Initialize kernel
 osInitKernel();
 /* USER CODE END 1 */
 /* MCU Configuration----------------------------------------------------------*/
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 /* USER CODE BEGIN Init */
 /* USER CODE END Init */
 /* Configure the system clock */
 SystemClock_Config();
 /* USER CODE BEGIN SysInit */
 /* USER CODE END SysInit */
 /* Initialize all configured peripherals */
 MX_TIM4_Init();
 //MX_ETH_Init();
 MX_DAC_Init();
 MX_TIM7_Init();
 /* USER CODE BEGIN 2 */
 
 
 InitProcessor();
 Clear_ETH_nReset_Pin();
 wait_ms(1);
 Set_ETH_nReset_Pin();
 wait_ms(1);
 MX_ETH_Init();
 
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?