Hi,
I am using stm32f105vct MCU and w5500 to establish ethernet communication using UDP protocol.
I am able to communicate b/w MCU and W5500 ic using SPI but when i tried to initialise socket for udp protocol , socket is always closed.I tried with all the sockets 0 to 8 but same problem.
I am getting PHYCFGR register value as 0xBB.
I have pasted my program below. Please help me to fine out the probelm .
Program:
uint8_t gate_way={0,0,0,0},sub_net={255,255,255,0},my_ip={192,168,0,6},dest_ip={192,168,0,2};
uint8_t udp_packets={10,20,30,40,50,60,70,80,90,100},read_data=0;
uint16_t prt=5000,dprt=5000;
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI2_Init();
MX_UART4_Init();
//UDP PROTOCOL*//
//Initialization
setSn_CR(0, Sn_CR_CLOSE);
setSn_CR(1, Sn_CR_CLOSE);
setSn_CR(2, Sn_CR_CLOSE);
setSn_CR(3, Sn_CR_CLOSE);
setSn_CR(4, Sn_CR_CLOSE);
setSn_CR(5, Sn_CR_CLOSE);
setSn_CR(6, Sn_CR_CLOSE);
setSn_CR(7, Sn_CR_CLOSE);
setGAR(gate_way);
setSUBR(sub_net);
setSIPR(my_ip);
setMR(MR_RST);
HAL_Delay(1000);
START:
// OPEN Socket4 Mode UDP MYPORT 5000
setMR(Sn_MR_UDP);
setSn_PORT(4, prt);
setSn_CR(4, Sn_CR_OPEN);
read_data= getSn_SR(4);
if(read_data !=SOCK_UDP)
{
setSn_CR(4, Sn_CR_CLOSE);
goto START;
}
//SET DESTIP 192.168.0.2 DESTPORT 7760
setSn_DIPR(4, dest_ip);
setSn_DPORT(4, dprt);
while (1)
{
wiz_send_data(4,udp_packets,sizeof(udp_packets));
setSn_CR(4, Sn_CR_SEND);
HAL_Delay(1000);
}
}
Thanks in Advance