Professional Documents
Culture Documents
W5500 UDP Problem - Open Hardware - W5500 Ethernet Shield - WIZnet Developer Forum
W5500 UDP Problem - Open Hardware - W5500 Ethernet Shield - WIZnet Developer Forum
MakerCommunity login
Wiki
window. E-Sale
Click the link to learn more about how to do it!
I am trying to interface W5500 with STM32f103c8t6 using UDP . Problem is I can’t send data
trough UDP socket but I can receive data from the UDP socket . Please help me to solve the
problem
Thank you
You have now written a question on the W5500 Ethernet Shield category. Are you using the
W5500 Ethernet Shield?
http://www.ebay.in/itm/112321091012?aff_source=Sok-Goog
STM32VLDISCOVERY - STMicroelectronics
STM32VLDISCOVERY - Discovery kit with STM32F100RB MCU, STM32VLDISCOVERY,
STMicroelectronics
I am trying to make an Echo server. Whatever data is sent to my chip via W5500 , data is returned
back to the PC. I have a C# program written by myself to send and receive data using UDP
socket. I am Monitoring communication by Wireshark. UDP send from PC is working ok. i can see
themain
Skip to datacontent
sent in wireshark and data is received without any problem in my C program. But when i
send the data back to the PC, Function SendData is stuck inside while(1) loop
such that Sok_0_INTR_Value is always 0x04. I neither get timeout or send_ok.Please drop me a
word if possible MakerCommunity Products Wiki
Thank You
while(1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 );
Delay(1,500);
GPIO_ResetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 );
Delay(1,500);
RecvCount = DataRecievedCheck();
if( RecvCount )
{
GetData(Data , &Count ,SCADAInfo); // Recieve Data
SendData(Data ,Count );
__disable_irq();
RecvCount = 0 ; // Atomic
__enable_irq();
Wiz_Setup_B_OPEN(); // Wiz UDP = Open-Close Socket every Time. Bu
}
}
return 1 ;
}
void Wiz_Setup_A_INIT(void)
{
unsigned short GAR = 0x0001 ; // Gateway 4 Bytes
unsigned short SUBR = 0x0005 ; // Subnet 4 Bytes
unsigned short SAR = 0x0009 ; // Source Hardware Address MAC - 6 Bytes
unsigned short SIPR = 0x000F ; // IP Address 4 Bytes
unsigned short RCR = 0x001B ; // Retry Count, Retry Attempts = RCR + 1,
unsigned
Skip to main content short SIMR = 0x0016 ; // Socket Interrupt Mask , Only enable for
// Reset
Delay(1,200); MakerCommunity Products Wiki
GPIO_ResetBits(GPIOA, Wiz_RST);
Delay(1,5); // Reset Time = 1.5 Mili Sec
GPIO_SetBits(GPIOA, Wiz_RST);
Delay(1,2);
unsigned char SIMRValue = 0x01 ; // Socket Interrupt Mask keep Socket Inte
Wiz_Write_Multi(SIMR , BSB_Common_Reg , &SIMRValue , sizeof(SIMRValue))
}
void Wiz_Setup_B_OPEN(void)
{
unsigned short Sok_0_Mod_Reg = 0x0000 ; // Mode Offet Address
unsigned char Sok_0_Mod_Value = 0x02 ; // Sock 0 Mode = 0x22 = UDP
* http://www.ebay.in/itm/112321091012?aff_source=Sok-Goog
* http://www.st.com/en/evaluation-tools/stm32vldiscovery.html
I am trying to make an Echo server. Whatever data is sent to my chip via W5500 , data is returned
back to the PC. I have a C# program written by myself to send and receive data using UDP
socket. I am Monitoring communication by Wireshark. UDP send from PC is working ok. i can see
the data sent in wireshark and data is received without any problem in my C program. But when i
send the data back to the PC, Function SendData is stuck inside while(1) loop such that
Sok_0_INTR_Value is always 0x04. I neither get timeout or send_ok. Physically there is a direct
connection by patch cable between W5500 and my laptop. and w5500 gateway defined as laptop
IP
Thank You
#include<stm32f10x.h>
#include<stm32f10x_gpio.h>
while(1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 );
Delay(1,500); // 500 Mili Sec
GPIO_ResetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 );
Delay(1,500); // 500 Mili Sec
RecvCount = DataRecievedCheck();
if( RecvCount )
{
GetData(Data , &Count ,SCADAInfo); // Recieve Data = Closes Soket
Skip to main content SendData(Data ,Count ); // Send Data = Closes Soket in
__disable_irq();
RecvCount = 0 ; // Atomic
__enable_irq(); MakerCommunity Products Wiki
Wiz_Setup_B_OPEN(); // Wiz UDP = Open-Close Socket every Time. Bu
}
}
return 1 ;
}
void Wiz_Setup_A_INIT(void)
{
unsigned short GAR = 0x0001 ; // Gateway 4 Bytes
unsigned short SUBR = 0x0005 ; // Subnet 4 Bytes
unsigned short SAR = 0x0009 ; // Source Hardware Address MAC - 6 Bytes
unsigned short SIPR = 0x000F ; // IP Address 4 Bytes
unsigned short RCR = 0x001B ; // Retry Count, Retry Attempts = RCR + 1,
unsigned short SIMR = 0x0016 ; // Socket Interrupt Mask , Only enable for
// Reset
Delay(1,200); // 200 Mili Sec
GPIO_ResetBits(GPIOA, Wiz_RST);
Delay(1,5); // Reset Time = 1.5 Mili Sec
GPIO_SetBits(GPIOA, Wiz_RST);
Delay(1,2); // 2 mili sec
unsigned char SIMRValue = 0x01 ; // Socket Interrupt Mask keep Socket Inte
Wiz_Write_Multi(SIMR , BSB_Common_Reg , &SIMRValue , sizeof(SIMRValue))
}
Skip tovoid
mainWiz_Setup_B_OPEN(void)
content
{
unsigned short Sok_0_Mod_Reg = 0x0000 ; // Mode Offet Address
unsigned char Sok_0_Mod_Value = 0x02 ; // Sock 0 MakerCommunity
Mode = 0x22 = UDPProducts Wiki
This is a working UDP code both by polling and interrupt , tested on STM32F100RB
#include<stm32f10x.h>
#include<stm32f10x_gpio.h>
#include<stm32f10x_rcc.h>
#include<stm32f10x_usart.h>
#include<stm32f10x_tim.h>
#include<stm32f10x_spi.h>
#include<stm32f10x_exti.h>
#include<misc.h>
// ip.addr == 192.168.1.12
while(1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 );
Delay(1,500);
GPIO_ResetBits(GPIOC, GPIO_Pin_8 | GPIO_Pin_9 );
Delay(1,500);
// RecvCount = DataRecievedCheck(); // if( RecvCount ) Polling
if( DataRecieved ) // Interrupt
{
DataRecieved = 0 ;
GetData(Data , &Count ,SCADAInfo); // Recieve Data = Closes S
Wiz_Setup_B_OPEN();
SendData(Data ,Count ); // Send Data = Closes Soke
Wiz_Setup_B_OPEN(); // Wiz UDP = Open-Close Socket every Time
}
}
return 1 ;
}
void Wiz_Setup_A_INIT(void)
{
unsigned short GAR = 0x0001 ; // Gateway 4 Bytes
unsigned short SUBR = 0x0005 ; // Subnet 4 Bytes
unsigned short SAR = 0x0009 ; // Source Hardware Address MAC - 6 Byt
unsigned short SIPR = 0x000F ; // IP Address 4 Bytes
unsigned short RCR = 0x001B ; // Retry Count, Retry Attempts = RCR +
unsigned short SIMR = 0x0018 ; // Socket Interrupt Mask , Only enable
// Reset
Delay(1,200);
GPIO_ResetBits(GPIOA, Wiz_RST);
Delay(1,5); // Reset Time = 1.5 Mili Sec
GPIO_SetBits(GPIOA, Wiz_RST);
Delay(1,2);
Your question seems to have already been solved in the following article
Thank you for providing a good reference.
Thanks for quick repply, i managed to solve the issue I get PING reply from W5500. i was
making 3 mistakes (1) i was sending data on a UDP socket which was not open , and after
this Polling methd recieve and transmit started to work as expected GetData(Data , &Count
,SCADAInfo); Wiz_Setup_B_OPEN(); // This Line was missing SendData(Data ,Count );
Wiz_Setup_B_OPEN(); later i wanted to use interrupt which was not working but i found out
following error (2) …
Well then develop the TCP code with Interrupt , test it and share it with me…