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.
11 years, 6 months ago.
SPI to ETH-UDP-Slave, max. available speed sending short messages
I would like to get your opinion about the mbed ETH-UDP-Speed.
I have to get a 16bit word via SPI, following by sending this value via UDP. 16bit value every 6microseconds and faster. Together 8192 x 16bit per cycle. Is it possible to manage this task using mbed? I've already deactivated the Checksum and set "set_blocking=false". Due to the above mentioned changes I've got a better performance but the mbed is freezing for timeouts below 5ms. The SPI routine is fast enough and working properly (checked w/o ETH). There are some comments can be found on "mbed.org", but I didn't find any description about the "bottleneck" (Not to mention the solution. Ohterwise: maybe there is no solution?).
Please find attached below the simple source code I'm using . Thank you and Best Regards, Georg
- include "mbed.h"
- include "EthernetInterface.h"
SPISlave device(p5, p6, p7, p8); mosi, miso, sclk, ssel
const char* ECHO_SERVER_ADDRESS = "192.168.1.90"; const int ECHO_SERVER_PORT = 60000;
int main() { device.format(16,0); device.frequency(25000000); probably not necessary
EthernetInterface eth; eth.init("192.168.1.100", "255.255.255.0", ""); Use hard IP-Address
unsigned int u_rfm=0;
UDPSocket sock; sock.init();
Endpoint echo_server; echo_server.set_address(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
char *u_buff;
while(1) { if(device.receive()) { u_rfm = device.read(); Read word from master u_buff=(char*)&u_rfm; sock.sendTo(echo_server, u_buff, sizeof(u_buff)); wait_us(300); } } }