1
NXPTM M522XX, KINETIS and i.MX RT / Re: Getting started with SPI devices
« on: November 11, 2014, 08:46:33 AM »
Ok, thank you for the heads-up, Mark! I will look into this further...
Nov 2020: uTasker i.MX RT V1.4.12 is productive - with complete secure loading concept.
Follow uTasker updates at www.twitter.com/uTasker !!
Online Forum registration has now been disabled. Please send an email to an address at the bottom of the home page with your preferred user name and email address if you would like an account.
Return to uTasker main site: www.utasker.com
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
You can however alread test the complete operation by connecting the PC (configured to be on the 10.10.10.x subnet) to the 8-port switch and configuring the FRDM-K64F to have IP addresses on both the 192.168.0.x and 10.10.10.x subnets but on its single Ethernet interface
The K64 has just one EMAC but if you need two complete Ethernet interfaces (for redundancy or multi-homed solutions you really only need to put in a Micrel KSZ8863 as PHY since this is a 3-port switch allowing 2 physically independent Ethernet connections to be created (costs may be $1 more than a standard PHY, plus a second RJ45 socket). This is supported in the project and allows it to be used as a switch (saving the need for external switches to attach multiple devices together or for redundancy) or as two controlable interfaces on a single EMAC (it has what is called tail-tagging operation which allows this and is supported by the EMAC driver). This avoids the need for further chips and SPI interface since all passes via the single MII interface!
Another technique is to use the final HW to interface with the SPI device but rather than have the complete application on the board just send each received packet (received via SPI) in a UDP frame to the simulator. The simulator runs the complete application with a UDP socket in place of the SPI interface so the real HW is an extension to it. Rather than sending generated frames to teh SPI they are sent in a UDP frame to the board, which passes it on to the SPI based device. Once application development is complete, remove the UDP socket and connect to the SPI HW instead.
In your case I would make use of the fact that the TCP/IP stack supports multiple networks and multiple network interfaces, especially if the Wiznet that you are using doesn't contain TCP/IP.
extern void fnMyFirstTask(TTASKTABLE *ptrTaskTable)
{
static unsigned char ucCounter = 0;
/*
fnDebugMsg("Hello, World! Test number ");
fnDebugDec(ucCounter++, 0);
fnDebugMsg("\r\n");
*/
static unsigned char ucRemoteIP[IPV4_LENGTH] = {192,168,0,112};
unsigned char data[MIN_TCP_HLEN + 4];
//memset( data, 0, 1024);
USOCKET test_client_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnTestTcpServerConnect);
if (test_client_socket >= 0) {
USOCKET ret;
if( (ret = fnTCP_Connect(test_client_socket, ucRemoteIP, 50000, 0, 0)) > 0) {
fnDebugMsg( "connected\r\n");
if( fnSendTCP(test_client_socket, data, 4, TCP_FLAG_PUSH) > 0) {
fnDebugMsg( "sent successfully\r\n");
} else {
fnDebugMsg( "send failed\r\n");
}
fnReleaseTCP_Socket( test_client_socket);
} else {
if( ret == SOCKET_NOT_FOUND)
fnDebugMsg( "Socket not found\r\n");
else if( ret == NO_FREE_PORTS_AVAILABLE)
fnDebugMsg( "No free ports available\r\n");
else if( ret == SOCKET_STATE_INVALID)
fnDebugMsg( "Socket state invalid\r\n");
}
} else {
if( test_client_socket == -2) {
fnDebugMsg( "No socket available\r\n");
}
}
}