• AVR Freaks

Hot!Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)?

Author
apunch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/06/12 15:42:03
  • Location: 0
  • Status: offline
2020/06/19 09:35:17 (permalink)
0

Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)?

I realise that the TCP/IP Lite Stack is meant for 8-bit MCU but the PIC24 is 16-bit. Is it easy to make changes to use the PIC24 with the TCP/IP Lite Stack, such as putting it in 8-bit SPI mode? I only need a lite stack, and am planning on using it with the ETH Click board (uses enc28j60).
 
 
#1
apunch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/06/12 15:42:03
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/07/22 13:47:49 (permalink)
4.67 (3)
EDIT: By the time this post got approved I have it working on XC16 compiler with the PIC24EP512GU810. To make it compatible you just have to set up SPI in 8-bit mode and change the defined CS, MISO, MOSI, SCLK and INT pins depending on how you connect the PIC24 to the ENC28J60. Make sure to create the project in MPLABX selecting the PIC24 device and then add in the AN1921 files.  
#2
aurora96
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/12/11 06:16:16
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/04 01:55:21 (permalink)
0
Hello,
I am using the same TCP/IP Lite Stack with pic32mz2048emf144, I've done many changes on the code, but it's still not working, it seems like it does not sent packets, How did you make it work?
#3
apunch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/06/12 15:42:03
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/04 10:02:28 (permalink)
0
@aurora96 If packets are not being sent, then it can be a problem with your SPI, or the way you initialized the ENC28J60.
 
You can test SPI by writing to the PHLCON register and turning on an LED (assuming you have an led connected). You can use the ENC28_PhyWrite function in the AN1921 stack. Look at the ENC28J60 datasheet on what to value to write to the PHLCON register to turn on an LED. Be sure to change the values of the CS, SCLK, MOSI and MISO pins based on your hardware. Also make sure you are using 8-bit SPI as the ENC28J60 only supports 8-bit. All the functions that write to the ENC28J60 use ETH_SPI_WRITE8(a) so make sure that function is defined as your SPI function. 
 
If you are certain your SPI is working, you can set the PHLCON register to blink every time you send a packet. If it is not blinking, check to see how you initialized the ENC28J60 in the ETH_Init function. How to initialize it and send packets is in the ENC28J60 datasheet. You can also use Wireshark to capture packets, but if your packets are not being captured it may also be due to the way Wireshark is configured. If you have linux, the 'any' interface is good at capturing almost all packets in the network. 
#4
aurora96
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/12/11 06:16:16
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/05 00:46:36 (permalink)
0
@apunch Thank you for your reply.
I a certain that the SPI is working: I changed the values of the CS, SCLK, MOSI and MISO pins based on my hardware. Also i am using 8-bit SPI as the ENC28J60 only supports 8-bit.
also i can write on the PHLCON register, i can see that when i send packets, led B is blinking, also with the softawre reset the led A blink.
My problem is i cant capture the packets i send.
#5
apunch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/06/12 15:42:03
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/05 10:00:49 (permalink)
0
@aurora96 If you have LEDB blinking when you send packets it is definitely a capture issue (unless the packet you are creating in the tx buffer is very malformed but if you are using the lite stack functions this is unlikely). If you are using Wireshark make sure the destination IP address is the same IP address as the computer you are running Wireshark on. You can find this address with the ipconfig or ifconfig command depending on if you are using Windows or Linux. You can also try sending it to the broadcast address 255.255.255.255 such as when sending an ARP request and see if you are able to capture that. Also make sure Wireshark is in promiscuous mode. 
If this still doesn't work you can try looking here https://ask.wireshark.org/questions/.
#6
aurora96
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/12/11 06:16:16
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/06 00:49:04 (permalink)
0
@apunch thank you a LOT for your help.
 
It is working now, it was an issue with the timer.
#7
apunch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/06/12 15:42:03
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/06 10:00:50 (permalink)
0
@aurora96  No worries - I am glad you figured it out!
#8
aurora96
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2019/12/11 06:16:16
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/07 06:57:51 (permalink)
0
@apunch im sorry to bother you again, i am testing another feautures on the code, have you tried the icmp to ping the module? it's not working on mine
#9
apunch
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/06/12 15:42:03
  • Location: 0
  • Status: offline
Re: Can you use the PIC24ep512gu810 with the Microchip TCP/IP Lite Stack (AN1921)? 2020/08/17 09:51:14 (permalink)
0
@aurora96 Just saw this now. I haven't looked into ICMP but was going to look into it this week. I think it uses ETH_Copy which uses DMA. I'll let you know if I get it working.
 
EDIT: If ETH_Copy does not work for you an easy method is to use ETH_ReadBlock(&tmpBuffer, dataLen) and ETH_WriteBlock(&tmpBuffer, dataLen) to copy the contents of the rx buffer (containing timestamp and data from icmp request) to the tx buffer. This method is likely slower than using the ENC28J60 DMA to transfer it but as I was using DMA with the PIC24 anyway it is still fairly fast. 
post edited by apunch - 2020/08/19 15:59:32
#10
Jump to:
© 2020 APG vNext Commercial Version 4.5