Hi,
We are using the W5500 (W550io board) with a STM32f417.
Until now, for testing purpose, we were working with a Terminal on PC (as a TCP Client) and the Wiznet module configured to be the TCP Server.
No problem in this case.
Now, we would like to use the Wiznet as a TCP Client. I did an initialization as it seems to be done on the datasheet but when I go to the step where I send the CONNECT Command, I always get SOCK_SYNSENT and then SOCK_CLOSED. I never get SOCK_ESTABLISHED.
I will put my initialization code here, maybe you will find my problem. Note that the WriteRegister function are working well because it works with the TCP Server configuration.
[code]// TCP Client
void vWIZNET_InitDeviceClient(void)
{
uint8_t __u8_SocketStatus = 0xFF;
uint8_t __au8_DataToWrite[4] = {0xC0, 0xA8, 0x01, 0x01};
vWIZNET_WriteRegisterValue(SOCKET_REGISTER_DIPR, SOCKET_0_REGISTER_BLOCK, __au8_DataToWrite, 4); // Set Destination IP address 192.168.1.1
__au8_DataToWrite[0] = 0x79;
__au8_DataToWrite[1] = 0x18;
vWIZNET_WriteRegisterValue(SOCKET_REGISTER_DPORT, SOCKET_0_REGISTER_BLOCK, __au8_DataToWrite, 2); // Set Destination port 31000
__au8_DataToWrite[0] = 0x01;
vWIZNET_WriteRegisterValue(SOCKET_REGISTER_MR, SOCKET_0_REGISTER_BLOCK, __au8_DataToWrite, 1); // Set TCP protocol
__au8_DataToWrite[0] = OPEN_COMMAND; //0x01
vWIZNET_WriteRegisterValue(SOCKET_REGISTER_CR, SOCKET_0_REGISTER_BLOCK, __au8_DataToWrite, 1); // Open command
vWIZNET_ReadRegisterValue(SOCKET_REGISTER_SR, SOCKET_0_REGISTER_BLOCK, &__u8_SocketStatus, 1); // Get socket status register
while(__u8_SocketStatus != 0x13); // SOCK_INIT
__au8_DataToWrite[0] = CONNECT_COMMAND; // 0x04
vWIZNET_WriteRegisterValue(SOCKET_REGISTER_CR, SOCKET_0_REGISTER_BLOCK, __au8_DataToWrite, 1); // Connect command
while(__u8_SocketStatus != 0x17) // SOCK_ESTABLISHED
{
vWIZNET_ReadRegisterValue(SOCKET_REGISTER_SR, SOCKET_0_REGISTER_BLOCK, &__u8_SocketStatus, 1); // Get socket status register
}
}[/code]
Thank you for your help,
Marc