7 years ago.

LPC1768 using a KSZ8864 for a PHY

Hi there

I have a custom LPC1768 board which has a KSZ8864 switch as the ethernet PHY. Has anyone any experience with this switch on mbed?

Using the code below it stops after the printf("B\n"); statement.

Any help would be appreciated.

Thanks in advance

#include "mbed.h"
#include "EthernetInterface.h"


extern "C" void mbed_mac_address(char * mac) {
 
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xf7;
    mac[3] = 0xf0;
    mac[4] = 0x45;
    mac[5] = 0xbe;           
  
};

int main() {
    printf("HelloWorld_3\n");
    wait(2);
    EthernetInterface eth;
    printf("A\n");
    eth.init(); //Use DHCP
    printf("B\n");
    eth.connect(10000);
    printf("C\n");
    printf("IP Address is %s\n", eth.getIPAddress());
    
    TCPSocketConnection sock;
    sock.connect("mbed.org", 80);
    
    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
    sock.send_all(http_cmd, sizeof(http_cmd)-1);
    
    char buffer[300];
    int ret;
    while (true) {
        ret = sock.receive(buffer, sizeof(buffer)-1);
        if (ret <= 0)
            break;
        buffer[ret] = '\0';
        printf("Received %d chars from server:\n%s\n", ret, buffer);
    }
      
    sock.close();
    
    eth.disconnect();
    
    while(1) {}
}

1 Answer

7 years ago.

It looks like you might be using an older version of the mbed library. I would suggest using the example linked here - https://os.mbed.com/docs/v5.6/reference/ethernet.html

Sarah, thanks for the link. Running the EthInterface example, it manages to return from the net.connect() with a -3012 error (NSAPI_ERROR_DEVICE_ERROR = -3012, /*!< failure interfacing with the network processor */). Is the connect / interfacing to the network processor documented anywhere. Is the phy I am using not compatible with the library?

posted by Erik Kearney 29 Nov 2017