Projects Home Schematics Datasheets Links    
   
Description

The Microchip PIC24FJ64GA002 is a fantastic addition to the 16-bit family of microcontrollers. For less than two bucks you get a 16MIPS 16-bit MCU with 64Kbytes of Flash Memory, 4KB of RAM, plenty of peripheral modules where you get to choose for most of them which one you connect to each pin, very flexible clock configurations, etc, all in a 28-pin package. Amazing !!!.

I was really anxious waiting for my first samples to arrive and put a basic reference design and test this new MCU with the Microchip TCP/IP stack.

The datasheet and PIC24F family reference manual were heavy lecture for a couple of days, I had to deal with a minor glitch in MPLAB IDE 7.60, but it didn't took too long for the first circuit to land on the protoboard and start spitting packets on the net.





PIC24FJ64GA002 Prototype
[Click Image to Enlarge]
In this project I will share with you two basic reference designs based on the PIC24FJ64GA002, one without LCD and the second with a character LCD module being driven through the SPI interface using a MCP23S08 port extender as I did for other similar projects.


Design considerations

The PIC24FJ64GA002 has plenty of peripherals that are very useful for a large variety of projects, and the Peripheral Pin Select (PPS) feature is very helpful but requires some previous thinking and planning.

I changed my mind couple of times and modified the pin selection configuration several times, but on the other hand it ended being a good exercise to grasp a clear understanding about how to use this feature and properly configure each peripheral.

To speed up the prototyping and get the first design running I chose to use the nic28 ENC28J60 board, and since I was planning to mix some 3.3V and 5V devices I included a 74ACT125 for level conversion.

Putting together the correct hardware configuration for the modified version of the TCP/IP stack took me some time, since we are mostly using 3.3V some devices like the 25LC256 serial EEPROM have to run at lower SPI clocks, then instead of configuring the SPI interface at the same clock rate for all devices or using the two available interfaces, I included in the code a better way to switch between SPI register configurations, which ended with the ENC28J60 with SCK = 8MHz, the 25LC256 at 4MHz, and the MCP23S08 at 5.33MHz.

I left RB5 and RB6 available since the I2C module is one of the peripherals that don't support PPS, and I was planning to use I2C to interface with a MCP9800 Temperature Sensor that is included in one of the schematics.

I'm still working on the final I2C code for the MCP9800 that will be included in a feature software update.


External memory

As mentioned before the design includes a 25LC256 Serial EEPROM that will be used for storing configuration information and HTTP server documents.


Microcontroller Clock Frequency

The PIC24FJ64GA002 uses a 8MHz crystal for the primary oscillator and 4xPLL is enabled to bring the internal clock to 32MHz.


Getting the board up and running

Like other similar projects compiling the firmware is a simple task, it requires few software tools available for download from Microchip's website at no cost, and obviously the TCP/IP stack source code distribution and a PIC programmer. For this project I used Microchip's MPLAB ICD2 as a programmer.

If you want to avoid the "glitch" from previous versions of MPLAB IDE, I recommend that you install 7.61 before compiling the software, if not you will find that your code only runs when you build a debug version and not when you build a release version (the actual problem is related to the handling of the COE-Clip On Emulation configuration bit in the device configuration script for this MCU).

With the latest modified version of the Microchip TCP/IP Stack v3.75, the process is quite simple.

This new version adds the PIC24FJ64_NIC28 macro definition that combined with the device selection for the Microcontroller and the particular hardware configuration file generates the appropriate code for this particular project.

This project adds two new hardware configuration files, pic24fj64.h for a design without a LCD module, and pic24fj64_lcd.h for a design with a LCD module driven using the SPI interface and a MCP23S08 I/O port extender.

The software distribution includes the MPLAB IDE project file PIC24FJ64.mcp, load this project into MPLAB IDE, select the correct processor (by default the project has selected the PIC24FJ64GA002) and verify that the settings on the config.h and hardware configuration files apply to your project or modify them accordingly (both files are located in the include subdirectory of the main src directory).

For additional details check the README.TXT file included in the software distribution.

For a detailed explanation about how to build Microchip's TCP/IP stack
for this or similar projects Click Here.


Schematics & Firmware source Code

Schematics for the PIC24GJ64GA002 Project  
Schematics for the PIC24GJ64GA002 + LCD via SPI Project  
Building the Microchip TCP/IP Stack for this project  


Datasheets for relevant parts used in this project

Microchip's PIC24FJ64GA004 Family 16-bit Microcontroller Datasheet  
Microchip's PIC24FJGA004 Family Errata A3  
Microchip's PIC24FJ64GA004 Family Datasheet Errata  
Microchip's PIC24F Family Reference Manual sections  
Microchip's ENC28J60 Ethernet Controller Datasheet (Version A)  
Microchip's ENC28J60 Ethernet Controller Datasheet (Version B - Latest)  
Microchip's ENC28J60 Silicon Errata Rev.B1  
Microchip's ENC28J60 Silicon Errata Rev.B4  
Microchip's ENC28J60 Silicon Errata Rev.B5  
Microchip's 25LC256 Serial EEPROM Datasheet  
Microchip MCP23S08 8-bit Port Expander  


Useful Links

TCP/IP Stack Source code and useful software tools

Microchip's TCP/IP Stack v3.02  
Microchip's TCP/IP Stack v3.60  
Microchip's TCP/IP Stack v3.75  
Microchip's TCP/IP Stack v4.02  
Microchip's TCP/IP Latest Version  
Microchip's MPLAB Integrated Development Environment  
Microchip's MPLAB C30 Compiler  
Wireshark (formerly Ethereal) Network Protocol Analyzer  
CoffeCup HTML Editor 2007  


Additional Resources

Brush Electronics Ethernet Boot Loader  
Microchip TCP/IP Stack Application Note (AN833)  
Microchip Users Forum - TCP/IP-Ethernet  




   
    ©2006-2009, Jorge Amodio, All rights reserved

Last Update: Jan 28, 2008