WIZ550io Ver1.3 using MPLab X IDE v6.0 and Wiznet_DHCP project with iolibrary
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: WIZ550io Ver1.3 using MPLab X IDE v6.0 and Wiznet_DHCP project with iolibrary
by WIZnet AI AI generated ·
RE: WIZ550io Ver1.3 using MPLab X IDE v6.0 and Wiznet_DHCP project with iolibrary
by Grace_Koo WIZnet ·
Hello, I’d like to provide a follow-up with additional details to complement the previous answer.
If you want to avoid a
while(getSn_SR() == SOCK_LISTEN)style of polling, you can use the INTn interrupt pin of the WIZ550io to handle connection events asynchronously. This allows your MCU to react only when needed, avoiding busy loops and saving CPU resources.By connecting the INTn pin to the external interrupt input of your MCU (typically configured for falling-edge), the MCU can detect the event and respond by checking the appropriate interrupt registers.
Reference:
Basic Workflow
listen().Sn_IMRregister for the target socket.Sn_IRregister, check for theSn_IR_CONbit, and handle the connection event.1back to the corresponding bit inSn_IR.Example Code
Notes
Sn_IMRregister must have the corresponding bit enabled to allow the interrupt to occur.Sn_IRmust be cleared by writing1back to the bit position (write-1-to-clear).If the issue is not resolved or if you have any further questions, please feel free to let me know.
Best regards,
Grace
RE: RE: WIZ550io Ver1.3 using MPLab X IDE v6.0 and Wiznet_DHCP project with iolibrary
by dbabayev ·
Both responses are perfect and seem very simple to implement but I cannot get past INTn (J2 pin 5) not moving.
It stays high even disconnected from MCU board.
I set the IMR right after socket opened and listen is successfully called.
I left same polling code beyond that and I monitor the INTn pin to see if it moves.
Is anything resetting the IR register during the polling before INTn is active?
I even replaced polling code with just a while(1) loop after socket opened and listen is successfully called, connection with client establishes in the background but no activity on INTn pin.
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "definitions.h"
#include "../src/ioLibrary_Driver-master/ioLibrary_Driver-master/Application/multicast/multicast.h"
#include "../src/ioLibrary_Driver-master/ioLibrary_Driver-master/Ethernet/W5500/w5500.h"
#include "../src/ioLibrary_Driver-master/ioLibrary_Driver-master/Ethernet/socket.h"
#include "../src/ioLibrary_Driver-master/ioLibrary_Driver-master/Internet/DHCP/dhcp.h"
// Constants
#define DATASOCKET 1
#define portNumber 23
// Global variables
uint8_t SOCK_DHCP = 0;
uint8_t gDATABUF[600];
int8_t retVal;
uint8_t sockStatus = 0;
char message[500] = " ";
// Network information structure
wiz_NetInfo networkInfo = {
.mac = {0x00, 0x08, 0xdc,0x.., 0x.., 0x..},
.ip = {192, 168, 1, 22},
.sn = {255, 255, 255, 0},
.gw = {192, 168, 1, 1},
.dns = {0,0,0,0},
.dhcp = NETINFO_DHCP
};
// Timeout configuration structure
wiz_NetTimeout gWIZNETTIME = {
.retry_cnt = 1, // RCR = 1
.time_100us = 1000 // RTR = 2000
};
// Function prototypes
void TIMER2_InterruptSvcRoutine(uint32_t status, uintptr_t context);
void network_init(wiz_NetInfo net);
void handleClientCommunication();
int main(void) {
// Initialization
SYS_Initialize(NULL);
wizInit();
// Set MAC address
setSHAR(networkInfo.mac);
// Initialize DHCP
DHCP_init(SOCK_DHCP, gDATABUF);
// Set up a timer interrupt to be called every second
TMR2_CallbackRegister(TIMER2_InterruptSvcRoutine, (uintptr_t)NULL);
TMR2_Start();
// Set network timeout
ctlnetwork(CN_SET_TIMEOUT, (void *)&gWIZNETTIME);
// Main Loop
while (1) {
if (getPHYCFGR() & PHYCFGR_LNK_ON) {
switch (DHCP_run()) {
case DHCP_IP_ASSIGN:
case DHCP_IP_CHANGED:
// Customize actions for IP assignment or change
break;
case DHCP_IP_LEASED:
// Handle network-related tasks when IP is leased
..... NOT USING DHCP NETWORK
break;
case DHCP_FAILED:
// Notify about DHCP failure
memset(message, 0, sizeof(message));
strcpy(message, ">> DHCP Retry Limit Exceeded\r\n");
UART1_Write(message, strlen(message));
// Stop DHCP and retry initialization
DHCP_stop();
// Notify applying default network settings
memset(message, 0, sizeof(message));
strcpy(message, ">> Applying Default Network Settings\r\n");
UART1_Write(message, strlen(message));
// Display default network information
memset(message, 0, sizeof(message));
sprintf(message, "Network Information:\r\n"
" Assigned IP: %d.%d.%d.%d\r\n"
" Subnet Mask: %d.%d.%d.%d\r\n"
" Gateway: %d.%d.%d.%d\r\n"
" DNS Server: %d.%d.%d.%d\r\n"
" MAC Address: %02X:%02X:%02X:%02X:%02X:%02X\r\n",
.....);
UART1_Write(message, strlen(message));
// Initialize network with default settings and handle client communication
network_init(networkInfo);
handleClientCommunication();
TMR2_Stop();
TMR2_CallbackRegister(TIMER2_InterruptSvcRoutine, (uintptr_t)NULL);
TMR2_Start();
DHCP_init(SOCK_DHCP, gDATABUF);
break;
default:
break;
}
} else {
// Handle error connecting
memset(message, 0, sizeof(message));
strcpy(message, ">> Error Connecting \r\n");
UART1_Write(message, strlen(message));
}
}
return EXIT_SUCCESS;
}
/* Initializes network settings */
void network_init(wiz_NetInfo net) {
setSn_KPALVTR(DATASOCKET, 1); // Set keep alive, 1 = 5 sec, 10 = 50 sec
ctlnetwork(CN_SET_NETINFO, (void*)&net);
}
/* This function is called after a period matches in Timer 3 (32-bit timer) */
void TIMER2_InterruptSvcRoutine(uint32_t status, uintptr_t context) {
LED2_Toggle();
DHCP_time_handler();
}
// Handles communication with the client //
void handleClientCommunication() {
if ((retVal = socket(DATASOCKET, Sn_MR_TCP, portNumber, 0)) == DATASOCKET) {
if ((retVal = listen(DATASOCKET)) == SOCK_OK) {
memset(message, 0, sizeof(message));
strcpy(message, ">> Looking for connection\r\n");
UART1_Write(message, strlen(message));
setSn_IMR(DATASOCKET, (getSn_IMR(DATASOCKET) | Sn_IR_CON));
while (1) {
;
}
}
}
RE: RE: WIZ550io Ver1.3 using MPLab X IDE v6.0 and Wiznet_DHCP project with iolibrary
by Grace_Koo WIZnet ·
Hello,
I'd like to share an example that demonstrates a simpler way to configure interrupts.
Please refer to the following GitHub repository:
https://github.com/WIZnet-ioNIC/WIZnet-PICO-FREERTOS-C.git
This project was originally created to use FreeRTOS with the Raspberry Pi Pico board, but please note that the
tcp_client_over_sslexample in the repository does make use of interrupts.For reference, the
dhcp_dnsexample in the same repository does not use interrupts.You'll find a useful file named
w5x00_gpio_irq.cunder thelibraries/iolibrary_driver/srcdirectory.The callback function used in this file is based on the Pico SDK, so please feel free to adapt it as needed to suit your own development environment.
Try using the functions defined in that file, and let me know how it goes.
I've also included a simple
tcp_serverexample that triggers an INTn interrupt only when a socket is connected.I hope this helps. Thank you.
Best regards,
Grace
// w5x00_loopback.c
// w5x00_gpio_irq.c (only socket connected)