Last year I just started learning PIC
microcontroller. While the variant of this uc only slightly sold at the
market in my country, but still some jobs offered by company requires it. As we know, Microchip
is a giant in microcontroller world and has been a long time player in
this field. Many engineer should already know about it or maybe have some experiences with it, meaning that abundant of information, support, help can be easily found on the net (forum, blog, whatever site), hence hopefully can make the learning
curve faster.
So I just started with PIC16F, then after spent several
days I managed to make the code working on PIC16F7x breadboarded. Satisfied
with that, then I moved to PIC18F. I had PIC18F4550 DIP package also
breadboarded, then I put the bootloader, play with USB CDC, USB HID, testing
the peripheral, but failed when tried to work with RTOS. Some
people credit it due to the segmented RAM PIC18F had, which is unsuitable for RTOS, and suggest to move to PIC24F instead.
And now here I decided to move from 8-bit PIC18F to 16-bit PIC24F. Since there’s no DIP version available for PIC24F, a PCB need to be designed and that what this post is about. The chip of choice is PIC24FJ256GB206.
To cut the time and avoid spending extra cash, it’s a good idea to take the reference from commercial working board. MPLAB Starter Kit for PIC24F MCU is used as my reference design.
And now here I decided to move from 8-bit PIC18F to 16-bit PIC24F. Since there’s no DIP version available for PIC24F, a PCB need to be designed and that what this post is about. The chip of choice is PIC24FJ256GB206.
To cut the time and avoid spending extra cash, it’s a good idea to take the reference from commercial working board. MPLAB Starter Kit for PIC24F MCU is used as my reference design.
There’re several aspects to consider during the board design. First is the SUPPLY. All PIC24FJ family devices power their core at nominal 1.8V. It has on-chip regulator that allow the device to run its core logic from VDD (typically 3.3V). On-chip regulator is enabled by tying ENVREG pin to VDD and 10uF capacitor must be put on VCAP pin. To provide 3.3V VDD from 5V source a regulator is required, MCP1727 is picked for that purpose. There're basically two powering scheme we can select, either bus powered or self powered:
Anyway, it's just a matter of selecting the 5V input for MCP1727 regulator, either taken from USB (Bus Powered) or from external source, e.g. battery, adaptor, etc (Self Powered). A jumper should be put on the PCB so it can select which source.
AVDD got supply from VDD through a low pass network consisting of 10 Ohm res + 0.1uF cap. AVSS and VSS is connected to the same ground plane, no need to separate them.
Next thing to consider is ICSP (In-Circuit Serial Programming) interface. I’ve the cheap PICKit3 and plan to use that for programming the device. So provide a programming header consist of 6 pin: VPP/MCLR, VDD, VSS, PGED, PGEC, PGM/LVP (though PGM/LVP is not used for serial programming PIC24F, can be left unconnected). Refer to the PICKit3 user guide for typical ICSP application circuit:
Next thing to consider is the clock source. PIC24F family has two oscillator: primary oscillator (OSCO & OSCI pin) and secondary oscillator (SOSCO & SOSCI pin). The primary will connected to 12MHz crystal + two 22pF ceramic cap, and the secondary will be connected to 32.768kHz RTC crystal (the tube one) + two 22pF ceramic cap. Those pins position are close to each other so PCB layout need to be handled carefully, a guard ring is put around the oscillator circuitry and all the GND/VSS pin of PIC are tied at one place then connected to the main ground plane.
Next again is put a switch to enter bootloader (picked DIP SW 1p switch) and a reset button (picked tactile switch).
Another very important thing to consider is the USB port. This is of course a must because PIC24F is a USB device (also support USB-OTG), picked mini female USB type-B. It is recommended to separate the ground plane between the USB and the device, then connect both the plane in one place through 0 Ohm res, I’ve seen a lot of design doing it this way, it’s believed to reduce noises and ESD (Electro Static Discharge) effect. Also the USB shield is grounded, and so the 4 mounting hole at each corner of PCB.
We're almost done, next all the I/O are outputted to the header, those pins are distributed to four of each 2x5 male header. Also PIC24F has JTAG pin (TMS, TCK, TDO, TDI), eventhough I honestly don’t plan to use it, anyway just outputted these 4 pins to the header, so doesn’t rule out the possibility of using it in the future.
For this board design I used DipTrace, PCB Design software that is simple, easy to use, and free (limited to 300 pin), I like it.
Schematic design (not too shabby this time):
The printscreen of the layout design:
They said that the biggest PCB manufacturer in the world currently is in China, so I used this opportunity to try one. Ok, so I researched several site and finally decided to put my bet on "pcbcart". I got the price for 5 PCB less than 30$. Several days passed then my PCB arrived, the quality of the PCB amazed me, indeed international manufacturer is differ, it’s very good:
After assembled/soldered:
After the board assembled, we’re going to put the bootloader so that it provide easy way for reprogramming (by just plugging the USB cable). Make a new project with MPLABX, then add every source files required to build the bootloader firmware. If MLA (Microchip Library for Application) already installed, the USB bootloader sources can be found at:
“C:\microchip\mla\v2017_03_06\apps\usb\device\bootloaders”, make sure to pick the right firmware that suit the device family (pic24_dspic) and for the USB framework sources can be located at: “C:\microchip\mla\v2017_03_06\framework\usb\src”.
The complete list of required source files is:
After adding all those sources to the project, then build and compile it in MPLABX (need to use XC16 PRO I think). Then get the .hex from “dist/default/production” on the project directory.
Connect PICKit3 to PIC24F board. We’ll use MPLAB IPE (advanced mode log in password ‘microchip’) to program the .hex to PIC24F flash ROM. To do that PICKit3 must be reverted back to MPLAB Mode. Also make sure at MPLAB IPE the correct operating voltage is selected as PICKit3 will power the targeted board from it.
After the bootloader has been programmed to PIC24F, now the next time we want to program the board we just simply plug USB cable then use HIDBootloader.exe apps to program the PIC. (HIDBootloader.exe can be found at
“C:\microchip\mla\v2017_03_06\apps\usb\device\bootloaders\utilities\bin\win”)
No comments:
Post a Comment