mikroICD Debugger Example

Here is a step by step mikroICD Debugger Example.


First you have to write a program. We will show how mikroICD works using this example:

program Lcd_Test

dim LCD_RS as sbit at RB4_bit
dim LCD_EN as sbit at RB5_bit
dim LCD_D4 as sbit at RB0_bit
dim LCD_D5 as sbit at RB1_bit
dim LCD_D6 as sbit at RB2_bit
dim LCD_D7 as sbit at RB3_bit

dim LCD_RS_Direction as sbit at TRISB4_bit
dim LCD_EN_Direction as sbit at TRISB5_bit
dim LCD_D4_Direction as sbit at TRISB0_bit
dim LCD_D5_Direction as sbit at TRISB1_bit
dim LCD_D6_Direction as sbit at TRISB2_bit
dim LCD_D7_Direction as sbit at TRISB3_bit

dim text as char[17]
    i    as byte

main:
  PORTB = 0
  TRISB = 0
  ANSEL  = 0
  ANSELH = 0
  text = "mikroElektronika"
  
  Lcd_Init()
  Lcd_Cmd(_LCD_CLEAR)
  Lcd_Cmd(_LCD_CURSOR_OFF)

  for i=1 to 17
    Lcd_Chr(1,i,text[i-1])
  next i

end.

After successful compilation and PIC programming press F9 for starting mikroICD. After mikroICD initialization blue active line should appear.



We will debug program line by line. Pressing F8 we are executing code line by line. It is recommended that user does not use Step Into [F7] and Step Over [F8] over Delays routines and routines containing delays. Instead use Run to cursor [F4] and Breakpoints functions.
All changes are read from PIC and loaded into Watch Window. Note that PORTB, TRISB, ANSEL and ANSELH changed its values.



Step Into [F7] and Step Over [F8] are mikroICD debugger functions that are used in stepping mode. There is also Real-Time mode supported by mikroICD. Functions that are used in Real-Time mode are Run/ Pause Debugger [F6] and Run to cursor [F4]. Pressing F4 goes to line selected by user. User just have to select line with cursor and press F4, and code will be executed until selected line is reached.



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

Breakpoints has been separated into two groups. There are hardware and software break points. Hardware breakpoints are placed in PIC and they provide fastest debug. Number of hardware breakpoints is limited (1 for P16 and 1 or 3 or 5 for P18). If all hardware brekpoints are used, next breakpoints that will be used are software breakpoint. Those breakpoints are placed inside mikroICD, and they simulate hardware breakpoints. Software breakpoints are much slower than hardware breakpoints. This differences between hardware and software differences are not visible in mikroICD software but their different timings are quite notable, so it is important to know that there is two types of breakpoints.

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