mikroICD Debugger Example
Here is a step-by-step mikroICD Debugger Example.

First you have to write a program. We will show how the mikroICD works using this example :
// Lcd module connections sbit LCD_RS at LATD0_bit; sbit LCD_EN at LATD1_bit; sbit LCD_D4 at LATB0_bit; sbit LCD_D5 at LATB1_bit; sbit LCD_D6 at LATB2_bit; sbit LCD_D7 at LATB3_bit; sbit LCD_RS_Direction at TRISD0_bit; sbit LCD_EN_Direction at TRISD1_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End Lcd module connections char text[] = "mikroElektronika"; char i; void Move_Delay() { Delay_ms(500); } void main() { ADPCFG = 0xFFFF; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); for(i = 1; i < 17; i++) { Lcd_Chr(1, i, text[i-1]); } }

After successful compilation and MCU programming press F9 to start the mikroICD. After the mikroICD initialization a blue active line should appear.


We will debug the program line by line. To execute code line by line press [F8]. However, it is not recommended to use Step Over [F8] over Delay routines and routines containing delays. In this case use Run to cursor [F4] function or Run [F6] function combined with Breakpoints.


Step Into [F7], Step Over [F8] and Step Out [Ctrl+F8] are mikroICD debugger functions that are used in stepping mode. There is also a Real-Time mode supported by the mikroICD. Functions that are used in the Real-Time mode are Run/Pause Debugger [F6] and Run to cursor [F4]. Pressing F4 executes the code until the program reaches the cursor position line.


Run(Pause) Debugger [F6] and Toggle Breakpoints [F5] are mikroICD debugger functions that are used in the Real-Time mode. Pressing F5 marks the line selected by the user for breakpoint. F6 executes code until the breakpoint is reached. After reaching that breakpoint Debugger halts. Here in our example we will use breakpoints for writing a word "mikroElektronika" on LCD char by char. Breakpoint is set on LCD_Chr and the program will stop every time this function is reached. After reaching breakpoint we must press F6 again to continue the program execution.

Breakpoints are divided into two groups: hardware and software breakpoints. The hardware breakpoints are placed in the MCU and provide fastest debugging. Number of hardware breakpoints is limited (4 for PIC24 and dsPIC33 family, for dsPIC30 family this number depends on the MCU used). If all hardware brekpoints are used, then the next breakpoint will be software breakpoint. These breakpoints are placed inside the mikroICD and simulate hardware breakpoints. Software breakpoints are much slower than hardware breakpoints. These differences between hardware and software breakpoints are not visible in the mikroICD software but their different timings are quite notable. That's why it is important to know that there are two types of breakpoints.
The picture below demonstrates step-by-step execution of the code used in above mentioned examples.


- Trying to program the MCU while the mikroICD is active.
- Trying to debug Release build version of the program with the mikroICD debugger.
- Trying to debug program code which has been changed, but has not been compiled and programmed into the MCU.
- Trying to select line that is empty for Run to cursor [F4] and Toggle Breakpoints [F5] functions.
- Trying to debug MCU with mikroICD while Watch Dog Timer is enabled.
- Trying to debug MCU with mikroICD while Power Up Timer is enabled.
- Trying to Step Into [F7] the mikroC PRO for dsPIC30/33 and PIC24 Library routines. Use Step Over [F8] command for these routines.
- It is not possible to force Code Protect while trying to debug MCU with mikroICD.
- Trying to debug MCU with mikroICD with pull-up resistors set to ON on RB6 and RB7.
What do you think about this topic ? Send us feedback!