cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 memory corruption

tbnkr
Associate II
Posted on July 24, 2015 at 16:47

Hello

I am doing a project with STM32F411RE and Microchip's ENC28J60 Ethernet-to-SPI chip. So far I have it working properly thanks to the code of www.tuxgraphics.com. However, my program exhibits some very peculiar behavior.

I have the following function that sends an ACK for a HTTP request, and then sends back the requested file in one segment only:

void www_server_reply(uint8_t *buf, const uint16_t dlen)

{

make_tcp_ack_from_any(buf,info_data_len,0); // send ack for http get

HAL_Delay(1); // Not working without this delay

buf[TCP_FLAGS_P]=TCP_FLAGS_ACK_V|TCP_FLAGS_PUSH_V|TCP_FLAGS_FIN_V;

make_tcp_ack_with_data_noflags(buf, dlen); // send data

}

Before calling this function, I have constructed the TCP segment. The first line sends an ACK for the HTTP GET, then some flags are added and the actual HTTP document is sent with the last line. Here comes my bug: without the delay of 1 ms, the function sends the same TCP segment as the previous one, which results in a duplicate ACK. If the delay is in place, the function works as expected by modifying the data before sending it.

When I step in the program with the debugger I cannot see the problem - it never happens. It occurs only when there's no delay, or I send two HTTP GET requests one after another without any delay in between. The strange thing is that even the flags are not modified - it is just resending the exact same packet.

I have one external interrupt which is modifying only one variable and I don't think it has something to do with the problem. I googled a lot but I could not find an answer.

Thanks

#stm32

0 REPLIES 0