You are on page 1of 12

PIC Simulator IDE Getting Started

There are eleven examples bundled with PIC Simulator IDE. They are located in application older. This is short step by step guide or the beginners that will help them to test these examples and in that way explore the most important eatures o PIC Simulator IDE. Example !" Timer# module simulation$ T%&# interrupts Example '" &(#)I*T external interrupts Example +" EEP&,% data memory access simulation Example -" %ath multiply routine$ demonstration o compiler$ assembler and debugger Example ." /)D module simulation Example 0" Comparator and voltage re erence modules simualtion Example 1" 2CD module simulation Example 3" 4ardware 5/&T module simulation Example 6" So tware 5/&T simulation inter ace Example !#" 17segment 2ED displays simulation Example !!" Signal generator and oscilloscope simulation modules E8/%P2E ! 7 Examine timer#.bas ile rom the application older. This (asic program uses Timer# module interrupts to periodically change the value on P,&T( pins. 9ile timer#.asm was generated using integrated (asic compiler. 9ile timer#.hex was generated using integrated assembler. TRISB = 0x00 'set all PORTB pins as outputs PORTB = %11111111 'make all PORTB pins high INTCON.T0I = 1 'ena!le Time"0 inte""upts INTCON.#I = T"ue 'ena!le all un$maske% inte""upts OPTION&R #.T0CS = 'alse 'set Time"0 (lo(k sou"(e to inte"nal inst"u(tion ()(le (lo(k n% On Inte""upt 'inte""upt "outine PORTB = PORTB $ 1 '%e("ement the *alue on PORTB INTCON.T0I' = 0 'ena!le ne+ T,R0 inte""upts Resume 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!093-< and clic: on Select button. 7 Clic: on 9ile;2oad Program. 7 Select timer#.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 This (asic program uses Timer# module interrupts to periodically change the value on P,&T( pins. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. *ote" I you would li:e to compile this example or some other PIC microcontroller model$ it might be necessary to change T#IE and T#I9 bit names to T%&#IE and T%&#I9. >ou should chec: in the datasheet o the model you want to use what are the correct bit names or I*TC,* register. 7 Screenshot" view

E8/%P2E ' 7 Examine rb#int.bas ile rom the application older. This (asic program uses &(#)I*T pin based interrupts to change the value on P,&T/. 9ile rb#int.asm was generated using integrated (asic compiler. 9ile rb#int.hex was generated using integrated assembler. TRIS- = 0x00 'set all PORT- pins as outputs PORT- = 0x.. 'make all PORT- pins high INTCON.INT = 1 'ena!le RB0/INT inte""upts INTCON.#I = 1 'ena!le all un$maske% inte""upts n% On Inte""upt 'inte""upt "outine PORT- = PORT- $ 1 '%e("ement the *alue on PORTINTCON.INT' = 0 'ena!le ne+ RB0/INT inte""upts Resume 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!093-< and clic: on Select button. 7 Clic: on 9ile;2oad Program. 7 Select rb#int.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 This (asic program uses &(#)I*T pin based interrupts to change the value on P,&T/. 7 Clic:ing on T button associated with &(#)I*T pin will :eep toggling the logical state o this pin. Interrupts will be triggered on the rising edge o the pulses. Every time the value on P,&T/ will be changed. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

E8/%P2E + 7 Examine eeprom.bas ile rom the application older. This example ills the whole data EEP&,%

memory and the enters an in inite loop. 9ile eeprom.asm was generated using integrated (asic compiler. 9ile eeprom.hex was generated using integrated assembler. 0im a -s B)te 'eep"om a%%"ess 0im ! -s B)te 'eep"om %ata 'o" a = 0 To 12 'go th"ough +hole eep"om memo") ! = 344 $ a 'set the %ata *alue to !e +"itten 5"ite a6 ! 'pe".o"m the +"iting to eep"om Next a 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!093-< and clic: on Select button. 7 Clic: on 9ile;2oad Program. 7 Select eeprom.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;EEP&,% %emory Editor. That will open the EEP&,% %emory Editor window. 7 &eposition the windows on the screen to get better view. 7 Clic: on ,ptions;Change EEP&,% ?rite Time. Enter !## or the new value and clic: on ,@. >ou should be very cautious when choosing this value$ because the realistic value is about '#### cloc: cycles at - %4A. In this simple example we will use short value$ because it can not a ect the unctionality o the program$ but can signi icantly decrease simulation execution time. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on ,ptions;In inite 2oop Stops Simulation to select that option. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 This example ills the whole data EEP&,% memory and the enters an in inite loop. 7 5pon detection o the in inite loop the simulator will automatically stop the simulation. 7 Screenshot" view

E8/%P2E 7 Examine multiply.bas ile rom the application older. This example will multiply two numbers !'+ Bhex 1(C and '+- Bhex E/C and get the result '313' Bhex 1#0EC. 9ile multiply.asm was generated using integrated (asic compiler. 9ile multiply.hex was generated using integrated assembler. 0im a -s 5o"% '.i"st num!e" 0im ! -s 5o"% 'se(on% num!e" 0im x -s 5o"% '"esult a = 132 'set .i"st num!e" ! = 327 'set se(on% num!e" x = a 8 ! '(al(ulate "esult 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!093-< and clic: on Select button. 7 Clic: on Tools;(/SIC Compiler 7 Clic: on 9ile;,pen 7 Select multiply.bas ile and clic: on ,pen. The basic source program will be displayed in the editor. 7 Clic: on Tools;Compile. The compiler will generate multiply.asm ile with assembler source and

display &/% %emory 5sage window. Clic: on Close to close it. 7 Close (/SIC Compiler window. 7 Clic: on Tools;/ssembler 7 Clic: on 9ile;,pen 7 Select multiply.asm ile and clic: on ,pen. The assembler source program will be displayed in the editor. 7 Clic: on Tools;/ssemble. / ter the operation is completed the assembler will generate two iles" multiply.lst and multiply.hex. The output ile multiply.lst will be displayed. 7 Close /ssembler window. 7 Clic: on 9ile;2oad Program. 7 Select multiply.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;(rea:points %anager. That will open the (rea:points %anager window. 7 Clic: on >es to use existing assembler listing ile. 7 &eposition the windows on the screen to get better view. 7 Clic: on the line corresponding to ##!1 address to de ine the brea:point on this instruction B2###'" G,T, 2###'C. 7 Select the 4old PC In 9ocus option 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 ?hen this mathematical routine is inished the program enters the in inite loop at the address ##!1$ but because o the brea:point$ the simulator will automatically switch to Step (y Step simulation rate. 7 >ou can stop the simulation now by clic:ing on Simulation;Stop or continue the execution by clearing the de ined brea:point and clic:ing on &ate;Extremely 9ast. 7 General purpose register pair B!647!34C will hold the irst argument ##1(. 7 GP& pair B!(47!/4C will hold the second argument ##E/. 7 The result 1#0E will reside in B!D47!C4C register pair. 7 Screenshot" view

E8/%P2E . 7 Examine adc.bas ile rom the application older. This program reads analog value on /*# analog input and displays 37bit conversion result on P,&T(. 9ile adc.asm was generated using integrated (asic compiler. 9ile adc.hex was generated using integrated assembler. S)m!ol a%&a(tion = -0CON0.#O&0ON 'set ne+ name .o" -/0 (on*e"sion sta"t !it S)m!ol %ispla) = PORTB 'set ne+ name .o" PORTB use% to %ispla) the (on*e"sion "esult TRISB = %00000000 'set PORTB pins as outputs TRIS- = %111111 'set PORT- pins as inputs -0CON0 = 0x(0 'set -/0 (on*e"sion (lo(k to inte"nal sou"(e -0CON1 = 0 'set PORT- pins as analog inputs 9igh -0CON0.-0ON 'tu"n on -/0 (on*e"te" mo%ule main: #osu! geta%"esult 'go to (on*e"sion "outine

%ispla) = -0R S9 '%ispla) the "esult o. the (on*e"sion #oto main '"epeat .o"e*e" n% geta%"esult: '(on*e"sion "outine 9igh a%&a(tion 'sta"t the (on*e"sion 5hile a%&a(tion '+ait until (on*e"sion is (omplete% 5en% Retu"n 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!09311< and clic: on Select button. 7 Clic: on 9ile;2oad Program. 7 Select adc.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 Clic: on / button associated with &/#)/*# pin. 7 5sing the slider change the analog value on this pin and clic: on /ccept button. 7 ?atch how this change a ect the state on P,&T( pins. 7 The last three steps can be repeated. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

E8/%P2E 0 7 Examine comp.bas ile rom the application older. This example uses analog comparator module to detect the state o /*# and /*! analog inputs in regard to '..= re erence voltage generated by internal module. 9ile comp.asm was generated using integrated (asic compiler. 9ile comp.hex was generated using integrated assembler. S)m!ol (omp&(hange = PIR1.C,I' '(ompa"ato" inte""upt .lag C,CON = 0x01 'set (ompa"ato" mo%e to t+o (ommon "e.e"en(e (ompa"ato"s +ith outputs TRIS- = 0x0; 'set R-06 R-1 an% R-3 as inputs6 othe" PORT- pins as outputs <RCON = 0xe( 'tu"n on6 (on.igu"e *oltage "e.e"en(e mo%ule .o" 3.4< an% (onne(t it to R-3 TRISB = 0x00 'set PORTB pins as outputs loop1: 5hile Not (omp&(hange '+ait .o" (ompa"ato" output (hange 5en% PORTB = C,CON '%ispla) C,CON "egiste" on PORTB pins6 RB1 an% RB; a"e (ompa"ato" outputs (omp&(hange = 0 '"eset (ompa"ato" inte""upt .lag #oto loop1 '"epeat .o"e*e" 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller.

7 Select <PIC!090'3< and clic: on Select button. 7 Clic: on 9ile;2oad Program. 7 Select comp.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on ,ptions;5se =oltage or /nalog Inputs to select this option. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 Clic: on / button associated with /*# or /*! pin. 7 5sing the slider change the analog value on that pin and clic: on /ccept button. 7 ?atch how this change a ect the state on P,&T/ and P,&T( pins. 7 The last three steps can be repeated. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

E8/%P2E 1 7 Examine lcd.bas ile rom the application older. This program reads analog value on /*# analog input and displays ormatted output on the attached 'x!0 2CD module. 9ile lcd.asm was generated using integrated (asic compiler. 9ile lcd.hex was generated using integrated assembler. 0e.ine -0C&C=OC> = 2 '%e.ault *alue is 2 0e.ine -0C&S-,P= ?S = 10 '%e.ault *alue is 30 0e.ine =C0&BITS = @ 'allo+e% *alues a"e 7 an% @ $ the num!e" o. %ata inte".a(e lines 0e.ine =C0&0R # = PORTB 0e.ine =C0&0BIT = 0 '0 o" 7 .o" 7$!it inte".a(e6 igno"e% .o" @$!it inte".a(e 0e.ine =C0&RSR # = PORT0 0e.ine =C0&RSBIT = 1 0e.ine =C0& R # = PORT0 0e.ine =C0& BIT = 2 0e.ine =C0&R5R # = PORT0 'set to 0 i. not use%6 0 is %e.ault 0e.ine =C0&R5BIT = 3 'set to 0 i. not use%6 0 is %e.ault 0e.ine =C0&CO,,-N0?S = 3000 '%ela) a.te" =C0C,0O?T6 %e.ault *alue is 4000 0e.ine =C0&0-T-?S = 40 '%ela) a.te" =C0O?T6 %e.ault *alue is 100 0e.ine =C0&INIT,S = 3 '%ela) use% !) =C0INIT6 %e.ault *alue is 100 'the last th"ee 0e.ine %i"e(ti*es set the *alues suita!le .o" simulationA the) shoul% !e omitte% .o" a "eal %e*i(e 0im an0 -s 5o"% TRIS- = 0x.. 'set all PORT- pins as inputs -0CON1 = 0 'set all PORT- pins as analog inputs =(%init 1 'initialiBe =C0 mo%uleA (u"so" is !linking loop: -%(in 06 an0 =(%(m%out =(%Clea" '(lea" =C0 %ispla) =(%out C-nalog input -N0C 'text .o" the line 1 =(%(m%out =(%=ine39ome 'set (u"so" at the !eginning o. line 3 =(%out C<alue: C6 Dan0 '.o"matte% text .o" line 3 5ait,s 1 'la"ge" *alue shoul% !e use% in "eal %e*i(e

#oto loop 'loop .o"e*e" 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!09311< and clic: on Select button. 7 Clic: on 9ile;2oad Program. 7 Select lcd.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 Clic: on Tools;2CD %odule. Clic: on >es or the 2CD %odule to load the setup parameters rom the basic program. That will open the 2CD %odule simulator window. B*ote" 2CD %odule parameters can be setup manually using Setup command.C 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 Clic: on / button associated with &/#)/*# pin. 7 5sing the slider change the analog value on this pin and clic: on /ccept button. 7 ?atch how this change a ect the 2CD %odule. 7 The last three steps can be repeated. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. *ote" /t the beginning o this simulation you will need to be patient$ because 2CD initialiAation seDuence will ta:e about !#ms o real time. ?atch &eal Time Duration ield. 7 Screenshot" view

E8/%P2E 3 7 Examine uart.bas ile rom the application older. This program irst sends 0 lines o ormatted output to hardware 5/&T serial port and then responds to the bytes received on that serial port by sending one line o ormatted text or every received byte. 9ile uart.asm was generated using integrated (asic compiler. 9ile uart.hex was generated using integrated assembler. 0im i -s B)te '%e(la"e a *a"ia!le 9se"open E100 'open ha"%+a"e ua"t po"t .o" !au% "ate E100 '5ait,s 1000 'this %ela) shoul% !e use% in a "eal %e*i(e 'o" i = 10 To 4 Step $1 '.o"$next loop 9se"out CNum!e": C6 Di6 C"=. 'sen% .o"matte% output to se"ial po"t '5ait,s 400 'this %ela) shoul% !e use% in a "eal %e*i(e Next i loop: 9se"in i '+ait to "e(ei*e a !)te on se"ial po"t 9se"out CNum!e": C6 Di6 C"=. 'sen% .o"matte% output to se"ial po"t #oto loop 'loop .o"e*e" 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!09311< and clic: on Select button. 7 Clic: on ,ptions;Change Cloc: 9reDuency. 7 Enter <-< and clic: on ,@ button.

7 Clic: on ,ptions;Change 5/&T Transmit)&eceive Time. 7 Enter <!##< and clic: on ,@ button. 7 Clic: on 9ile;2oad Program. 7 Select uart.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;4ardware 5/&T Simulation Inter ace. That will open the window or inter acing hardware 5/&T during the simulation. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 ?ait until the program has inished sending 0 lines o ormatted text to the serial port. 7 5sing one o three available buttons in the 5/&T Input section o the 5/&T inter ace send a byte to the serial port. 7 ?atch how program responds by sending one line o ormatted output. 7 The last two steps can be repeated. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

E8/%P2E 6 7 Examine so tuart.bas ile rom the application older. This program irst sends 0 lines o ormatted output to so tware 5/&T serial port BT8 line" P,&T(.!C and then responds to the bytes received on that serial port B&8 line" P,&T(.'C by sending one line o ormatted text or every received byte. 9ile so tuart.asm was generated using integrated (asic compiler. 9ile so tuart.hex was generated using integrated assembler. 0e.ine S RO?T&0 =-F?S = 400 0im i -s B)te '%e(la"e a *a"ia!le '5ait,s 1000 'this %ela) shoul% !e use% in a "eal %e*i(e 'o" i = 10 To 4 Step $1 '.o"$next loop Se"out PORTB.16 E1006 CNum!e": C6 Di6 C"=. 'sen% .o"matte% output to PORTB.1 GTH line o. so.t+a"e ?-RTI '5ait,s 400 'this %ela) shoul% !e use% in a "eal %e*i(e Next i loop: Se"in PORTB.36 E1006 i '+ait to "e(ei*e a !)te on PORTB.3 GRH line o. so.t+a"e ?-RTI Se"out PORTB.16 E1006 CNum!e": C6 Di6 C"=. 'sen% .o"matte% output to se"ial po"t #oto loop 'loop .o"e*e" 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!093-< and clic: on Select button. 7 Clic: on ,ptions;Change Cloc: 9reDuency. 7 Enter <-< and clic: on ,@ button. 7 Clic: on 9ile;2oad Program. 7 Select so tuart.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;So tware 5/&T Simulation Inter ace. That will open the window or inter acing

so tware 5/&T during the simulation. 7 De ault settings should be set" &8 2ine 777E P,&T(.'$ T8 2ine 777E P,&T(.!$ (aud &ate 777E 60##$ 2ogic 2evels 777E Standard. I not$ using commands rom Settings menu ma:e the necessary changes. 7 Clic: on ,ptions;Compact %icrocontroller =iew to select it. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;5ltimate B*o &e reshC simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 ?ait until the program has inished sending 0 lines o ormatted text to the serial port. Pay attention to the state o P,&T(.! pin on the %icrocontroller =iew window. 7 5sing one o three available buttons in the 5/&T Input section o the 5/&T inter ace send a byte to the serial port. Pay attention to the state o P,&T(.' pin on the %icrocontroller =iew window. 7 ?atch how program responds by sending one line o ormatted output. 7 The last two steps can be repeated. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

E8/%P2E !# 7 Examine 1segment.bas ile rom the application older. This program displays numbers rom # to 66 on the two 17segment 2ED displays with parallel connection and two enable lines using T%&# interrupt multiplexing procedure. 9ile 1segment.asm was generated using integrated (asic compiler. 9ile 1segment.hex was generated using integrated assembler. 0im 0im 0im 0im 0im 0im 0im 0im %igit -s B)te 'input *a"ia!le .o" # T,-S> su!"outine %igit1 -s B)te '(u""ent high %igit %igit3 -s B)te '(u""ent lo+ %igit mask -s B)te 'output *a"ia!le ."om # T,-S> su!"outine mask1 -s B)te '(u""ent high %igit mask mask3 -s B)te '(u""ent lo+ %igit mask i -s B)te phase -s Bit

S)m!ol %1ena!le = PORTC.0 'ena!le line .o" highe" ;$segment %ispla) S)m!ol %3ena!le = PORTC.1 'ena!le line .o" lo+e" ;$segment %ispla) TRISB = %00000000 'set PORTB pins as outputs TRISC.0 = 0 'set RC0 pin as output TRISC.1 = 0 'set RC1 pin as output %1ena!le = 'alse %3ena!le = 'alse mask1 = 0 mask3 = 0 phase = 0 INTCON.T0I = 1 'ena!le Time"0 inte""upts INTCON.#I = 1 'ena!le all un$maske% inte""upts OPTION&R #.T0CS = 0 'set Time"0 (lo(k sou"(e to inte"nal inst"u(tion ()(le (lo(k

loop: 'o" i = 0 To EE %igit1 = i / 10 'get (u""ent high %igit %igit3 = i ,o% 10 'get (u""ent lo+ %igit T,R0 = 0 '"eset Time"0 to p"e*ent its inte""upt !e.o"e !oth masks a"e %ete"mine% %igit = %igit1 #osu! getmask 'get mask .o" high %igit mask1 = mask %igit = %igit3 #osu! getmask 'get mask .o" lo+ %igit mask3 = mask #osu! sho+1 '%ispla) ne+ mask #osu! sho+3 '%ispla) ne+ mask 5ait?s 400 '%ela) inte"*al suita!le .o" simulation 'use la"ge %ela) .o" the "eal %e*i(e6 sa) 5-IT,S 400 Next i #oto loop n% On Inte""upt 'Time"0 inte""upt "outine '(ontinuousl) s+it(h !et+een high an% lo+ %igit %ispla)s I. phase = 0 Then phase = 1 #osu! sho+1 lse phase = 0 #osu! sho+3 n%i. INTCON.T0I' = 0 'ena!le ne+ T,R0 inte""upts Resume getmask: 'get app"op"iate ;$segment mask .o" input %igit mask = =ook?pG0x2.6 0x016 0x4!6 0x7.6 0x116 0x1%6 0x;%6 0x0;6 0x;.6 0x1.I6 %igit Retu"n sho+1: 'sho+ high %igit on its %ispla) %3ena!le = 'alse PORTB = mask1 %1ena!le = T"ue Retu"n sho+3: 'sho+ lo+ %igit on its %ispla) %1ena!le = 'alse PORTB = mask3 %3ena!le = T"ue Retu"n 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!09311< and clic: on Select button. 7 Clic: on ,ptions;Change Cloc: 9reDuency. 7 Enter <-< and clic: on ,@ button. 7 Clic: on 9ile;2oad Program. 7 Select 1segment.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;17Segment 2ED Displays Panel. That will open the window with our 17segment displays. 7 Clic: on Setup button below the display number '. 7 Clic: twice on the orange ield next to the Display Enable label to select pin that will be used to enable)disable this display. 7 Select P,&TC.# and then clic: on Select. 7 Clic: on Setup button below the display number !. 7 Clic: twice on the orange ield next to the Display Enable label to select pin that will be used to enable)disable this display. 7 Select P,&TC.! and then clic: on Select. 7 Clic: on the 4ide Setup button to save some screen space. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;5ltimate B*o &e reshC simulation rate.

7 Clic: on Simulation;Start. The simulation will start immediately. 7 The program will display numbers rom # to 66 on the two 17segment 2ED displays using T%&# interrupt multiplexing procedure. 7 Experiment with the @eep 2ast Display option. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

E8/%P2E !! 7 Examine i'c.bas ile rom the application older. This routine programs the irst +' locations in the external serial EEP&,% device using I'C communication protocol. In this example it is used to demonstrate oscilloscope and signal generator simulation modules. 9ile i'c.asm was generated using integrated (asic compiler. 9ile i'c.hex was generated using integrated assembler. 0im a%%" -s 5o"% '*a"ia!le .o" sto"ing 0im %ata -s B)te '*a"ia!le .o" sto"ing PRO, !)te a%%"ess PRO, !)te %ata

S)m!ol s%a = PORTC.3 'ni(kname .o" S0- pin S)m!ol s(l = PORTC.2 'ni(kname .o" SC= pin 'o" a%%" = 0 To 21 'the .i"st 23 !)tes +ill !e +"itten %ata = 344 $ a%%" 'set the %ata !)te to !e +"itten I3C5"ite s%a6 s(l6 0xa06 a%%"6 %ata 'pe".o"m I3C +"ite ope"ation to se"ial PRO, 5ait,s 1 'small %ela) inte"*al Next a%%" 7 Start PIC Simulator IDE. 7 Clic: on ,ptions;Select %icrocontroller. 7 Select <PIC!09311< and clic: on Select button. 7 Clic: on ,ptions;Change Cloc: 9reDuency. 7 Enter <-< and clic: on ,@ button. 7 Clic: on 9ile;2oad Program. 7 Select i'c.hex ile and clic: on ,pen. That will load the program into PIC program memory. 7 Clic: on Tools;,scilloscope. That will open the our channel digital oscilloscope window. 7 Clic: on Settings;Turn ,n), ,scilloscope Channel !. 7 Select P,&TC.' and then clic: on Select. 7 Select Pull7up option or channel ! pin. 7 Clic: on Settings;Turn ,n), ,scilloscope Channel '. 7 Select P,&TC.+ and then clic: on Select. 7 Select Pull7up option or channel ' pin. 7 Clic: on Settings;Turn ,n), ,scilloscope Channel +. 7 Select P,&T(.# and then clic: on Select. 7 Clic: on Settings;Turn ,n), ,scilloscope Channel -. 7 Select P,&T(.! and then clic: on Select. 7 Clic: on Tools;Signal Generator. That will open the our channel continuous pulses generator. 7 Clic: on Settings;Turn ,n), Signal Generator !. 7 Select P,&T(.# and then clic: on Select. 7 Enter .## to de ine period or channel ! pulses and then clic: on ,@. 7 Enter '. to de ine duty cycle or channel ! pulses and then clic: on ,@.

7 Clic: on Settings;Turn ,n), Signal Generator '. 7 Select P,&T(.! and then clic: on Select. 7 Enter !### to de ine period or channel ' pulses and then clic: on ,@. 7 Enter .# to de ine duty cycle or channel ' pulses and then clic: on ,@. 7 Clic: on Tools;%icrocontroller =iew. That will open the %icrocontroller =iew window. 7 &eposition the windows on the screen to get better view. 7 Select the &ate;Extremely 9ast simulation rate. 7 Clic: on Simulation;Start. The simulation will start immediately. 7 I'C communication can be observed on the oscilloscope module as well as the pulses generated by the signal generator. 7 The simulation can be stopped any time by clic:ing on Simulation;Stop. 7 Screenshot" view

You might also like