Using MPLAB® ICD 2 Debugger

  Important :

To successfully use MPLAB® ICD 2 Debugger with generated .cof file, follow the steps below :

  1. First of all, start mikroBasic PRO for PIC and open the desired project.
  2. Open Tools › Options › Output settings, and check the "Generate COFF file" option, and click the OK button.
  3. Next, enable Background Debug bit in the Edit Project menu.
  4. After that, compile the project by pressing Ctrl + F9.
  5. Connect USB cable and turn on power supply on EasyPIC6.
  6. Program the MCU by pressing F11.
  7. Connect external power supply, USB cable from PC and modular interface cable to the MPLAB® ICD 2 Debugger's appropiate sockets, like on the picture below :
  8. MPLAB® ICD 2 Debugger Connection

  9. Connect second end of the modular interface cable to the EXT ICD (RJ12) socket of EasyPIC6 :
  10. Connecting modular interface cable to the EasyPIC6

  11. Picture below illustrates the proper connection of ICD 2 to EasyPIC6 :
  12. Connecting MPLAB® ICD 2 Debugger to the EasyPIC6

  13. Next, open MPLAB®, and select the appropriate device by choosing Configure › Select Device... For example, 16F887 MCU will be selected :
  14. Configure Device

  15. After device selection, click on the File › Import. Open file dialog box should appear. Then, go to the project folder and open the generated HEX file, UART.hex.

      Note : This is very important, because hex file contains configuration bit settings which are essential for the proper functioning of the user code.

  16. Next, click the File › Import. Open file dialog box should appear. Then, go to the project folder and open the generated COFF file, UART.cof :
  17. Import COFF file

  18. Then, select the MPLAB® ICD 2 from the Debugger › Select Tool menu for hardware debugging :
  19. Select Debugger

  20. Complete the MPLAB® ICD 2 Setup Wizard from the Debugger menu.
  21. After completing MPLAB® ICD 2 Setup Wizard, click on the Debugger › Connect :
  22. Connect to the device

  23. Finally, click on the Debugger › Program :
  24. Program device

  25. Now, you can start debugging the code by clicking Step Over button Step Over Button on the Debug toolbar, or by pressing F8 :
  26. Code Debugging

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code