EesyPIC v7 with PIC32MZ2048EFH144 - ethernet problem!

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 32-bit PIC MCUs
Post Reply
Author
Message
ducbkfet
Posts: 2
Joined: 26 Apr 2020 19:22

EesyPIC v7 with PIC32MZ2048EFH144 - ethernet problem!

#1 Post by ducbkfet » 26 Apr 2020 20:18

Hi MikroElektronika,

I have just got the easyPIC v7 board with pic32mz2048efh144 and been trying with ethernet connection for two weeks now with no results. I am new to this and will be very appreciated for any helps you guys can lend me!

My project requires a large amount of data transferring in real-time, so I intended to build a datalink from the microcontroller to my laptop via the Ethernet protocol. My set up is just a direct connection via a crossover cable. I followed the ethernet_demo example and modified it a bit (attached here) to suit my project. I set static IP addrs for the microcontroller and my laptop as followed:

PIC:
unsigned char myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f}; // my MAC address
unsigned char myIpAddr[4] = {192, 168, 20, 59 }; // my IP address
unsigned char gwIpAddr[4] = {192, 168, 20, 6 }; // gateway (router) IP address
unsigned char ipMask[4] = {255, 255, 255, 0 }; // network mask (for example : 255.255.255.0)
unsigned char dnsIpAddr[4] = {192, 168, 20, 1 }; // DNS server IP address

Laptop:
IP: 192, 168, 20, 60;
Gateway, subnet mask and dns are the same with PIC.
Laptop ethernet IP4.JPG
Laptop ethernet IP4.JPG (54.14 KiB) Viewed 2249 times
The problem is the connection seems fine. I checked every register of the PHY LAN9720's and PIC's and found nothing wrong. The auto-negotiation was successful, link was up and no remote fault. However, I couldn't ping the microcontroller from the laptop.
ping.JPG
ping.JPG (27.81 KiB) Viewed 2249 times
I tried function ethernet_sendUDP() to send packages to the laptop's IP and the program got stuck there. I also used Matlab to connect the controller and send packages out to the microcontroller. Of course, it didn't connect... From Wireshark, the protocol stuck at arp trying to ask for "Who has 192.168.20.1?". From my shallow knowledge that I just gained over this week, this seems it is asking for the DHCP protocol, which is provided by routers to automatically assign ip addr and stuff to devices connecting to the network. I would like to avoid routers and I used function Ethernet_confNetwork() to set up network params for PIC.
Wiresharks.JPG
Wiresharks.JPG (216.97 KiB) Viewed 2249 times
The same crossover cable worked fine when I tested with 2 laptops. I was able to ping from both sides. The data generated from Matlab on one side were received successfully on the other side also using Matlab.

At this point, I am out of ideas about what I should do... Any helps from you guys will be much appreciated.

Looking forward to your responses.

Regards,
Duc.

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: EesyPIC v7 with PIC32MZ2048EFH144 - ethernet problem!

#2 Post by stefan.filipovic » 30 Apr 2020 09:16

Hi Duc,

Have you tried connecting the board directly to the router via an ethernet cable?

Kind regards,
Stefan Filipović

Post Reply

Return to “PIC32 PRO Compilers”