Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 4 months ago.
interrupts & wiz550io (w5500)
Does anyone get interrupts from w550io?
I need an interrupt each time a new message is available on websocket.
I added those two rows but it seems not working.
eth.reg_wr(0x0016,240); //IMR eth.reg_wr(0x0018,255); //SIMR
(eth is a WiznetInterface)
1 Answer
10 years, 2 months ago.
Hi This is my answer for solving your problem.
First of all, If you want to use socket interrupt of W5500, you have to set SIR(Socket Interrupt) and SIMR(Socket Interrupt Mask).
And then you can check Sn_IR(Socket n Interrupt) for checking interrupt event of W5500.
This is my test code. (Note: In order to clear the Sn_IR bit, the host should write the bit to '1' )
include the mbed library with this snippet
#include "mbed.h" #include "W5500Interface/EthernetInterface.h" #include "Websocket.h" #define TARGET_KL25Z int main() { #if defined(TARGET_KL25Z) Serial pc(USBTX, USBRX); pc.baud(115200); printf("spi init\r\n"); SPI spi(D11, D12, D13); // mosi, miso, sclk wait(1); // 1 second for stable state EthernetInterface eth(&spi, D10, D9);//scs(D10), nRESET(PTA20) printf("App Start\r\n"); wait(1); // 1 second for stable state #endif eth.init(); //Use DHCP eth.connect(); printf("IP Address is %s\r\n", eth.getIPAddress()); // this code from http://mbed.org/teams/mbed/code/Websocket_Ethernet_HelloWorld/file/bd0a76c1d9d0/main.cpp // view @ http://sockets.mbed.org/demo/viewer Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw"); // For test eth.reg_wr<uint8_t>(0x0018,0xFF); // SIMR printf("1. TEST S0_IR value = %x\r\n",eth.sreg<uint8_t>(0,0x0002)); ws.connect(); printf("2. TEST S0_IR value = %x\r\n",eth.sreg<uint8_t>(0,0x0002)); eth.sreg<uint8_t>(0,0x0002,0x0005); printf("3. TEST S0_IR value = %x\r\n",eth.sreg<uint8_t>(0,0x0002)); char str[100]; for(int i=0; i<0x10; ++i) { sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : No Sensor", i); ws.send(str); // clear the buffer and wait a sec... memset(str, 0, 100); wait(0.5f); // websocket server should echo whatever we sent it if (ws.read(str)) { printf("rcv'd: %s\r\n", str); } } ws.close(); eth.disconnect(); while(1) { } }
Don't know whether it's relevant anymore, but you need to enable Sn_IMR as well.
posted by Jörg Straube 15 Jul 2017