
#Mplab xc8 vs c18 code#
The demo code simply echoes back any characters sent, so if you send "abc", you should see: The status section should show that you're connected. Now, if you run the TCPIP_Demo.jar GUI file from AN1921, you should be able to go to the TCP Client Demo tab, put in the IP address of the PIC-WEB, port 7 and click connect. If you run the project, assuming you're plugged into the network and properly configured (IP, netmask, etc.) you should notice that you can ping the device. Lastly, you need to include the tcp_server_demo.h file (#include "tcp_server_demo.h" at the top).īuilding shows quite a few warnings from the generated code, but seem mostly mundane. Also, in the while (1) loop, add Network_Manage() and DEMO_TCP_EchoServer(). In your main.c, enable your interrupts by uncommenting the INTERRUPT_GlobalInterruptEnable() and INTERRUPT_PeripheralInterruptEnable() lines. h files from the AN1921 code to your project. 19.įor this example, I'm going to add the TCP server demo. Here's where you can follow along with the specific examples from AN1921. That way accidentally running MCC again won't clobber the files. If you don't want to ever use MCC again and/or plan to modify the generated files, you can delete your mc3 file and move everything out of mcc_generated_files. When you go back to your project, you'll see a bunch of MCC Generated files with all the TCP/IP stuff in it. You can configure other code if you'd like, otherwise next to "Project Resources" click the "Generate" button, and save/close MCC. That's all there is to configuring it through MCC. Lastly, under Pin Manager I selected both ports A0 and A1 to be outputs, which enables the two Ethernet LEDs (alternatively, you could do this with TRISA in your code).

In my case, I have UDP, IPV4, TCP, ICMP, and ARP checked, so we can ping the device, and run all the TCP and UDP demos from AN1921. Under "Project Resources" click TCP/IP Lite, select which protocols you want enabled (uncheck DHCP if you want a static IP, then set your static IP). Then change the Prescaler to 1:8, and (as noted in the new warning), change the Timer Period to 50ms and the Callback Function Rate to 20, in order to get a Callback Rate of (roughly) 1 second.
#Mplab xc8 vs c18 mac#
You can also set your MAC address here.įrom as noted in the WARNING, click TMR1 and check "Enable Timer Interrupt". This gets rid of some of the extra things that were added because it was assuming an external MAC/PHY. First, drop down "Ethernet" and click "MAC", then select "ETHxxJ6x". This seems to add a few things to the "Project Resources".

Under "Device Resources" click the '+' on TCP/IP Lite
#Mplab xc8 vs c18 software#
As you're going through this, be sure to read the INFO, HINT, and WARNING Notifications.Ĭonfigure system module as desired (for maximum 41.667 MHz, change to HSPLL, set external clock to 25 MHz, enable Software PLL) Here, you can start to follow along on page 3 of the AN1921 PDF, though it's a bit different for our chip, so I've detailed it below. Open MPLAB Code Configurator (creating the new mc3 file)

I was able to create a functional project using the current (at this time) versions of MPLAB X v5.45, XC8 v2.31, MCC v4.0.2. Microchip has a newer TCP/IP Lite Stack which supports XC8 (AN1921: ), but that AN doesn't directly support the PIC18F97J60 family (with the integrated MAC and PHY).Īfter a bit of digging, I found that the PIC18F97J60 family is supported by MCC, and uses the same TCP/IP Lite Stack from AN1921, meaning we can use MCC to create the TCP/IP project for the PIC-WEB board, then use the sample application code from AN1921 for sample TCP and UDP functions. My understanding is that all of the sample projects available under "SOFTWARE" on the PIC-WEB product page are based on the old TCP/IP stack and only support the (old/unsupported) C18 compiler. I was helping a colleague get Ethernet code running on a PIC-WEB board (PIC18F67J60), and there seemed to be a lot of confusion regarding Ethernet support using the XC8 compiler.
