cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet on stm32f767 For Dummies

Eld_Eddan
Associate

Hi,

I have a background in electrical engineering but am a complete beginner with embedded engineering. I've bought two nucleo f767zi boards with the goal to send information between them using Ethernet with the built in rj45 port. 

My goal right now is to utilize the built in user button to light a LED on the other board. Once i get a working initial code ill be able to build on it from there. However, im struggling a lot to even get the initial code working. I'm using the stm32cube and after a lot of reading i've decided to go for FREErtos(cmsis V2) and lwip using the netconn API (although raw would work as well). 

The two boards will utilize the same code but i will manually comment out one of these two lines (743 or 744) in the code before flashing the boards.

//tcpecho_init();

ping_init();

 

 

My problem right now is that the code leaves the ping_thread after this line and do not seem to come back no matter if i press the button. (line 601)

semaphore_status = xSemaphoreTake(xSemaphoreButton, portMAX_DELAY);

 

I'm assuming this is trivial things that i've yet to understand. I'll post my code bellow, which im sure is full of multiple errors and unnecessary lines.

Any help, big or small, will be greatly appreciated.

My main.c

1 ACCEPTED SOLUTION

Accepted Solutions
STea
ST Employee

Hello @Eld_Eddan ,

After a quick review of the code you shared it seems like you are missing some important steps to make your example work reliably and ensure that the kernel of FreeRtos is doing its job you need to configure another clock source as timebase (a timer) for HAL calls used by drivers in your code and by surcharging the HAL delay function you are not insuring the 1ms tick needed for HAL API calls to work correctly .
here is an extract from the Readme :

@note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
      based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
      a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
      than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
      To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.


you can see the examples in this GitHub repo to see the proper way of configuring a LWIP project with RTOS.
you can use this example as a good reference already implementing the ability to ping your board.

you can see also this article to help you get started with LWIP :How to create a project for STM32H7 with Ethernet ... - STMicroelectronics Community


Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
STea
ST Employee

Hello @Eld_Eddan ,

After a quick review of the code you shared it seems like you are missing some important steps to make your example work reliably and ensure that the kernel of FreeRtos is doing its job you need to configure another clock source as timebase (a timer) for HAL calls used by drivers in your code and by surcharging the HAL delay function you are not insuring the 1ms tick needed for HAL API calls to work correctly .
here is an extract from the Readme :

@note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
      based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
      a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
      than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
      To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.


you can see the examples in this GitHub repo to see the proper way of configuring a LWIP project with RTOS.
you can use this example as a good reference already implementing the ability to ping your board.

you can see also this article to help you get started with LWIP :How to create a project for STM32H7 with Ethernet ... - STMicroelectronics Community


Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.