Showing results for 
Search instead for 
Did you mean: 

Wrong values getting assigned when same structure assignment is done.

Associate III

I am developing an TCP/IP Server Client application on my NUCLEO-F207ZG  development board.I am implementing a function to send ADC values on Ethernet.

void Client_Data_Send(void)
char temp_buff[TEMP_BUFF_SIZE];
volatile uint32_t buff_len;
volatile uint16_t Temperature = 0;
struct pbuf *p = NULL;

Temperature = TEMP;

buff_len = sprintf(temp_buff,"DHT11 Sensor value from TCP Client : %u \n\r",Temperature);

/*allocate pbuf from ram*/
p = (pbuf_alloc(PBUF_TRANSPORT,buff_len,PBUF_POOL));

(tcp_client->p)= (p);

if(tcp_client->p != NULL)
/*copy the data to send into the allocated pbuf*/
pbuf_take( tcp_client->p ,(char *)temp_buff,buff_len);

/*send data*/
tcp_client_send(tx_pcb, tcp_client);

/*free mem*/
pbuf_free( tcp_client->p);


Above is the function I implemented.

At line (tcp_client->p)= (p); when I debuged I came to know that values are not getting assinged.

Below are the screen shot.



since wrong values for all members getting assigned I am facing Hard fault issue. Is it structure alignment issue? I am using LwIP library for Tcp/Ip application.


ST Employee

Hello @pradeepwagre ,

At first glance this code seems to have some issues and it is not conformed to the guidelines of implementation with LWIP on STM32s.

You can follow this User Manual Developing applications on STM32Cube with LwIP TCP/IP stack
to get more info bout the way to use LwIP tcp/ip stack.
you can check the way to use LwIP either with or without Rtos and take this following example as reference.

STM32CubeF2/Projects/NUCLEO-F207ZG/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS at master · STMicroelectronics/STM32CubeF2 (

You can also implement and example using LwIP without RTOS by following this Application Note (see section 4.1.2) in which we implement a periodic process in While(1) loop.




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.