2010-11-08

Quick start with the Microchip Explorer 16 board

Quick start with the Microchip Explorer 16 board

(with standard PIC24FJ128GA010 PIM)





1 - Programmer

The board have dedicated connectors for a PICkit 2/PICkit 3 or ICD2/ICD3 programmer.
While I have a ICD3, we really don't need it. A direct USB cable from the computer to the board USB connector(J8) is enough.
The board was designed with a auxiliary MCU, the PIC18LF4550(U2), that was supposed, as it seems, to offer equivalent features to a PICkit 2.
Unfortunately Microchip never shipped the firmware needed to enable this feature.
Fortunately Rafal Waniurski did.

To update the PIC18LF4550(U2) to work as a programmer follow:
1 - Install PICkit 2 tool (latest as of 2010-11-08 PICkit 2 v2.61).
2 - Connect the board to power(J12) and a USB cable from J8 to the PC.
3 - Open PICkit 2 tool.

* you might get a error "PICkit 2 VDD and VPP voltage level errors.", just ignore it. Click OK and continue.
4 - Click Tools -> Download PICkit 2 Operating System, choose file PK2_Explorer16_V0210022.hex. The programming starts. It should take about 15s, and if it completes successfully you can read "PICkit 2 connected. ID = OIHoss".
5 - This will probably fail the first time. That is because the PICkit 2 tool will try to connect to the PIC18LF4550(U2) to verify the programing, but this will happen while windows is installing the driver for the new firmware you just flashed. While it probably is already working, you might repeat the previous step to get the successfully message.
*If this fails, your PIC18LF4550(U2) might be not programed from factory with a USB bootloader. In that case, you will need to use a regular programmer for loading this firmware(use PK2_Explorer16_V0210022-BL.hex instead).






2 - My first program

1 - Install MPLAB IDE and MPLAB C30. MPLAB IDE is free. MPLAB C30 have evaluation and free versions for academic use.
2 - Make sure Jumper J7 is set to "PIC24" Side and Switch S2 is set to "PIM" side
3 - Connect the board to power(J12) and a USB cable from J8 to the PC.
4 - Download explorer16_demo_v1.zip and unzip it.
5 - Double-click explorer16_demo.mcp to load the project in MPLAB.
6 - Click Project -> Build all.
7 - Select Programmer -> Select Programmer -> 8 PICkit 2.
8 - Click Programmer -> Program.

9 - Click Programmer -> Release from Reset.


* If you get a programming error or each time you reconnect the power/usb cable, you will need to click Programmer -> Connect.
* If you click Programmer -> Dowload OS, the vanilla PICkit 2 firmware will be loaded in the PIC18LF4550(U2), and the programmer will not work anymore. You will need to flash the PIC18LF4550(U2) with the Rafal Waniurski modified firmware to get it working again. That must be done with the PICkit 2 tool.


You are done.
The program behavior is explained in the main.c file header.






3 - Starting to write code

Microchip is known for making MCUs with "trilions" of peripherals. A PIC24 will have ADCs, Comparators, Timers, Low-power modes, Watchdog, UARTs, ...
That integration allows to reduce the number of components, saving board space, power and money.

Mastering all this features is not a simple task, and you will need to read the full bible(s).

1 - Peripherals Libraries

(C:\Program Files (x86)\Microchip\MPLABC30\docs\periph_lib\Microchip PIC24F Peripheral Library.chm)
* My demo program is using adc library, notice line "#include <adc.h>".
2 - Standard C Library

(C:\Program Files (x86)\Microchip\MPLAB C30\docs\hlpLib30.chm)
* My demo program is using the standard c input and output library, notice line "#include <stdio.h>".
3 - PIC24FJ128GA010 Family Data Sheet
http://ww1.microchip.com/downloads/en/DeviceDoc/39747e.pdf
4 - PIC24F Family Reference Manuals
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en024805
* There is one Reference Manual for each Peripheral/Module. You should check this together with the Data Sheet. The Reference Manual explain in more detail, but might be only partially applicable to your MCU. The datasheet will clarify what your specific MCU has or hasn't.
5 - Explorer 16 Development Board User Guide
http://ww1.microchip.com/downloads/en/DeviceDoc/Explorer%2016%20User%20Guide%2051589a.pdf

Even if you read all this twice you will probably still don't get the entire picture. Buying a book might help:
Lucio Di Jasio, Programming 16-Bit PIC Microcontrollers in C: Learning to Fly the PIC 24, ISBN 0-7506-8292-2

For last, a useful trick to reduce the code/compile/program/debug/code/compile/program/debug/code
cycle is to activate the auto-program option in MPLAB. That way after changing the code, you only need to click "Make" and MPLAB will automatically compile and program the MCU for you.
1 - Select Programmer -> Settings -> Program after a sucessful build.

2 - Select Programmer -> Settings -> Run after a successful program.

References
[1]
Lucio Di Jasio, Programming 16-Bit PIC Microcontrollers in C: Learning to Fly the PIC 24, ISBN 0-7506-8292-2

2 comments:

Afonso said...

Porque é que o meu blog não é BEMBOM?

Unknown said...

Um blog e uma irmã não se querem iguais.