PIC Lab Manual1 - الصفحات الشخصية

Transcription

PIC Lab ManualPIC LabManual2010/20111Include CD-ROM

PIC Lab ManualTable Of ContentsExperiment #1Introduction to Software Tools MPLAB, PROTEUS, andQL-2006 programmer.3Experiment #2Introduction to PIC16F84A6Experiment #3Some Logic Functions Design9Experiment #4Delay Loops Applications Flasher & Counter12Experiment #5Interrupt Application Controlling flashing speed of aflasher15Experiment #6TMR0 Application Counter Using TMR018Experiment #7EEPROM Memory Application22Experiment #8Introduction to MikroC Language26Experiment #9Application for Interrupt using MikroCIqama System30Experiment #10Application for Keypad and LCDSecurity System33Experiment #11Analog Digital Conversion39Experiment #12Pulse-width modulation (PWM)442

PIC Lab ManualLab 1Introduction to Software ToolsMPLAB, PROTEUS, and QL-2006 programmerObjectives1. To be familiar with some software tools like MPLAB, PROTEUS, and ICPROG.2. To know how to make a project using MPLAB and then get the hex file ofthe software program of the project.3. How to simulate the hex file using PROTEUS.IntroductionThese programs are the backbone of the microprocessor and microcontroller basedsystems; since using MPLAB we can build the software of the project using C or Assemblylanguage, and then we can simulate the project virtually using PROTEUS, finally we candownload the program on the microcontroller and see the results practically using ICPROG.So this experiment includes all the knowledge the student will need to get started to theseprograms.1. MPLAB Program What is MPLAB?MPLAB is a software program that runs on your PC to provide a developmentenvironment for your embedded system design.In other words it is a Windows program package that makes writing and developinga program easier. It could best be described as developing environment for astandard program language that is intended for programming microcontrollers. Get started to MPLAB1.2.3.4.5.6.Open the program by double clicking on its icon on the desktop.From the project menu choose project wizard.Choose PIC 16F84A.Brows and name the project.From view menu choose project; to view the project.Then add a file to the source files by right clicking on source files, andchoose add files and then name the file anyName.asm.3

PIC Lab Manual2. PROTEUS Program What is PROTEUS?Proteus contains everything you need to develop, test and virtually prototype yourembedded system designs based around the Microchip Technologies PIC16 seriesof microcontrollers. The unique nature of schematic based microcontroller simulationwith Proteus facilitates rapid, flexible and parallel development of both the systemhardware and the system firmware. This design synergy allows engineers to evolvetheir projects more quickly, empowering them with the flexibility to make hardware orfirmware changes at will and reducing the time to market.Proteus VSM models will fundamentally work with the exact same HEX file as youwould program the physical device with, binary files (i.e. Intel or Motorola Hex files)produced by any assembler or compiler. How to setup PROTEUS?1. Start-up the Microsoft Windows.2. Place the ECOM 4315 CD into CD ROM drive.3. Double click on the software tools folder and then choose Proteus Simulator afterthat double click Proteus 7.1 folder and run the setup.4. Press next until you reach the window which ask for the key.5. From browse for key; browse until you reach the same folder where the setupexists, and then open the second folder and chose the MAXIM LICENCE folder.6. Then click on the top icon which is MAXIM and then press install.7. Then choose yes and then close the window, after that browse and install theprogram.8. After that run the patch which exist in the same folder where theMAXIM LICENCE exists.9. Then browse for c:\Program files\Labcenter electronics \Proteus.10. Finally chose next, and then finish. Get started to PROTEUS1.2.3.4.5.From start menu chose the PROTEUS, and then chose ISIS(blue).To get a part click on Devices ( P ).Write the name of the PIC16F84A.To get LED write led then chose green led.To get a resistor write 1k and chose the first part.4

PIC Lab Manual3. QL-2006 programmerQL-2006 programmer is the high-speed programmer designed specially fordevelopment and production programming of PIC single chipmicrocomputer (SCM) by Shenzhen Qianlongsheng Electronic TechnologyCo., Ltd. The product is featured with small volume, low powerconsumption, high reliability as well as easy and convenient operation.QL-2006 is applicable for almost all PIC10/12/16/18 series SCMs except16C5X. It also supports memories in 24XX series and 93XX series. Hardware InstallationThere is no special requirement for installation of this programmer. Connectprogrammer to PC through serial port cable or USB cable and power up,then the programmer works. (This programmer supports direct USB powersupply. If USB cable is connected, you may not connect external power.However, if current through USB interface is very low – less than 200MAand insufficient to drive programmer, connection to external power isrequired to enable the programmer to work regularly.) Software InstallationFind file QL-PROGvXXen.EXE under root directory of CD, double clickthis file to access installation interface of application software, and operateaccording to prompts to finish the installation. Its shortcut will appear ondesktop automatically after installation. Running of SoftwareAfter proper installation, shortcut of this software will appear on desktop.We can double click it to run the software.

PIC Lab ManualLab 2Introduction to PIC16F84AObjectiveTo get familiar with programming and using PIC16F84 microcontroller.ToolsPIC16F84 Microcontroller, IC programmer, MPLAB software.TheoryA microcontroller (or MCU) is a computer-on-a-chip. It is a type ofmicroprocessor emphasizing self-sufficiency and cost-effectiveness, in contrastto a general-purpose microprocessor (the kind used in a PC).A microcontroller is a single integrated circuit, commonly with the followingfeatures: central processing unit - ranging from small and simple 4-bitprocessors to sophisticated 32- or 64-bit processors input/output interfaces such as serial ports (UARTs) Other serial communications interfaces like I²C, Serial PeripheralInterface and Controller Area Network for system interconnect Peripherals such as timers and watchdog RAM for data storage ROM, EPROM, EEPROM or Flash memory for program storage clock generator - often an oscillator for a quartz timing crystal, resonatoror RC circuit many include analog-to-digital convertersPIC16F84 microcontrollerPIC16F84 belongs to a class of 8-bit microcontrollers of RISCarchitecture. Its general structure is shown on the following maprepresenting basic blocks.PIC16F84 has a total of 18 pins. It is most frequently found in a DIP18 type of6

PIC Lab Manualcase but can also be found in SMD case which is smaller from a DIP. DIP is anabbreviation for Dual In Package. SMD is an abbreviation for Surface MountDevices suggesting that holes for pins to go through when mounting aren'tnecessary in soldering this type of a component.Pins on PIC16F84 microcontroller have the following meaning: Pin no.1 RA2 Second pin on port A. Has no additional function Pin no.2 RA3 Third pin on port A. Has no additional function. Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer isalso found on this pin Pin no.4 MCLR Reset input and Vpp programming voltage of amicrocontroller Pin no.5 Vss Ground of power supply. Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function. Pin no.7 RB1 First pin on port B. No additional function. Pin no.8 RB2 Second pin on port B. No additional function. Pin no.9 RB3 Third pin on port B. No additional function. Pin no.10 RB4 Fourth pin on port B. No additional function. Pin no.11 RB5 Fifth pin on port B. No additional function. Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode. Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode. Pin no.14 Vdd Positive power supply pole. Pin no.15 OSC2 Pin assigned for connecting with an oscillator Pin no.16 OSC1 Pin assigned for connecting with an oscillator Pin no.17 RA2 Second pin on port A. No additional function Pin no.18 RA1 First pin on port A. No additional function.7

PIC Lab ManualProcedurePart 1 Connect the circuit shown in the figure Write an assembly language program that send 0x8a to port B Load the program to the microcontrollerPart 2 Connect the circuit shown in the figureWrite an assembly program that inputs data from port A and sends it to port BProgram a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.Part 3 Present your results in a lab report including a copy of the source codes.8

PIC Lab ManualLab 3Some Logic Functions DesignObjectives1. To know how to design some logic functions like Addition, Subtraction, andMultiplication using the microcontroller PIC16F84A.2. To know how to simulate these functions using PROTEUS program.3. To know how to program the microcontroller PIC16F84A and then simulatethese Logic Functions using hardware.Tools PIC16F84A microcontroller.MPLAB software.PROTEUS software.QL2006 USB Programmer.TheoryIn this experiment we will implement the Addition and Subtraction FunctionsUsing PIC16F84A microcontroller. Addition and subtraction functionsThe addition function is summarized as follow :9

PIC Lab Manual1. We use the method of masking to separate the two numbers, since the firstnumber is in the LSB of PORTB and the second number is in the MSB, weseparate the first number using the instruction ANDLW 0X0F, and the secondnumber using the instruction ANDLW 0XF0.2. After that before we add the two numbers, the first number is ready foraddition but the second number needs to be swapped, so we use the instructionSWAPF F,d to swap it (swapping means F(0:3) F(4:7), F(4:7) F(0:3)).3. After that we add the two numbers using the instruction ADDWF F,d and thenwe display the result on PORTA.The subtraction function is the same as the addition function except you willsubtract the two numbers instead of adding them. To avoid negative answer thefirst number must be greater than the second .ProcedurePart 1: Addition Function Write an assembly program to achieve the addition of two numbers entered toport B and display the result on port A.Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulated.Program a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.10

PIC Lab ManualPart 2: Subtraction Function Write an assembly program to achieve the subtraction of two numbersentered to port B and display the result on port A.Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulated.Program a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.Part 3 Present your results in a lab report including a copy of the source codes.11

PIC Lab ManualLab 4Delay Loops ApplicationsFlasher & CounterObjectives4. To know how to make a delay loop with a certain value.5. To realize how PIC16F84A microcontroller deals with timing issues.6. To get familiar with interfacing 7-Seg display to PIC16F84A and make acounter.7. To get familiar with interfacing LED display to PIC16F84A and make aflasher.ToolsPIC16F84A microcontroller, MPLAB software, PROTEUS software, USBProgrammer.TheoryThere is two methods to generate Delay is PIC16F84A Microcontroller: The first method is using TMR0, which is a built in timer in PIC16F84Amicrocontroller. The second method is using Delay Loops Technique.In this experiment we will know how to generate a Delay with a certain valueusing the Delay Loops Technique; after that we will use this delay to make someapplications like Flasher and Counter.The Ordinary Instructions need 1 cycle to be executed, but the cycles which causethe program counter (PC) to be changed need 2 cycles.ExamplesMovlw .100 Î needs 1 cycle.Movwf portb Î needs 1 cycle.Call delay Î needs 2 cycles.Goto loopÎ needs 2 cycles. And so on.12

PIC Lab ManualDelay SubroutineConsider the following delay subroutine:DELAYMOVLW .255MOVWF 0CHLOOP1MOVLW .255MOVWF 0DHLOOP0(1)NOP.(n)NOPDECFSZ 0DH,FGOTO LOOP0DECFSZ 0CH,FGOTO LOOP1RETURNENDHow to calculate the value of the Delay for this subroutine?1) Look for the inner Loop13(# of NOPS) 1(DECFSZ 0DH,F) 2(GOTO LOOP0) 162) Intermediate Loop1(MOVLW .255) 1(MOVWF 0DH) 1(DECFSZ 0CH,F) 2(GOTOLOOP1) 53) Outer Loop1(MOVLW .255) 1(MOVWF 0CH) 2(RETURN) 4So the value of the delay is(16*255*255 5*255 4)*(4/Osc Freq) 1.04sec (if Osc Freq 4MHz).Note that this value of the delay is not precise 100%, since we ignore that theinstruction DECFSZ needs 2 cycles in the last turn, and hence this method(Delay Loops Method) is not effective for precise and large values of Delay.13

PIC Lab ManualProcedurePart 1: Flasher Write an assembly program to make a Flasher on RB0 (Hint: Use the DelaySubroutine).Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulatedProgram a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.Part 2: Counter Write an assembly program to make a Counter (0 – 9) on Port A. RB0 (Hint:Use the Delay Subroutine).Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulatedProgram a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.Part 3 Present your results in a lab report including a copy of the source codes.14

PIC Lab ManualLab 5Interrupt ApplicationControlling flashing speed of a flasherObjectives8. To know what is the interrupt, and how many sources of interrupt does thePIC16f84A microcontroller have.9. To know how to make interrupt on PORTB through (RB4 – RB7).10. To get familiar with interfacing LED display to PIC16F84A and make aflasher.11. To know how to change the flashing speed of this flasher using interruptsmethod.ToolsPIC16F84A microcontroller, MPLAB software, PROTEUS software, USBProgrammer.TheoryInterrupts allow a microcontroller to respond to some events at the moment theyoccur, regardless of what the microcontroller is doing at the time. This provides aconnection between a microcontroller and the external environment. Generally,each interrupt changes the program flow, interrupts it and after executing aninterrupt service routine continues on from that same interrupt point. Thefollowing figure illustrates this15

PIC Lab ManualThe PIC16F84A has 4 interrupt sources1.2.3.4.Termination of writing data to EEPROM.TMR0 interrupt caused by timer overflow.Interrupt during alteration on RB4, RB5, RB6 and RB7 pins of port B.External interrupt from RB0/INT pin of microcontroller.In this experiment we will deal only with one of these sources, which is the interruptduring alteration on (RB4 – Rb7).Interrupt upon a change on pins 4, 5, 6 and 7 of port BChange of input signal on PORTB 7:4 sets RBIF (INTCON 0 ) bit. Four pinsRB7, RB6, RB5 and RB4 of port B, can trigger an interrupt which occurs whenstatus on them changes from logic one to logic zero, or vice versa. For pins to besensitive to this change, they must be defined as input. If any one of them isdefined as output, interrupt will not be generated at the change of status. If theyare defined as input, their current state is compared to the old value which wasstored at the last reading from port B.Keeping the contents of important registersSome registers which are already in use in the main program can also be in use ininterrupt routine. If they were not retained, main program would during a returnfrom an interrupt routine get completely different values in those registers, whichwould cause an error in the program. Examples for such a case are the contents ofthe work register W, and the status register. If we suppose that main program wasusing work register W for some of its operations, and if it had stored in it somevalue that's important for the following instruction, then an interrupt whichoccurs before that instruction would change the value of work register W whichwould directly be influenced the main program.We use the instruction SWAPF F,d to save the contents of these registersbecause it doesn't affect the Status Register.1. How to save the contents2. How to restore the contents16

PIC Lab ManualProcedure Write an assembly program to make a Flasher on RA0; then use the interruptmethod to control the flashing speed of this flasher.Hint// Use the interrupt on change (RB4 – RB7) Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulated Program a PIC 16F84A using the QL2006 programmer. Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.Part 2 Present your results in a lab report including a copy of the source codes.17

PIC Lab ManualLab 6TMR0 ApplicationCounter Using TMR0Objectives12. To know what is the free run timer TMR0; and the function of this timer.13. To know how to make a counter using TMR0.ToolsPIC16F84A microcontroller, MPLAB software, PROTEUS software, USBProgrammer.TheoryTimers are usually most complicated parts of a microcontroller, so it isnecessary to set aside more time for their explaining. With their application it ispossible to create relations between a real dimension such as "time" and a variablewhich represents status of a timer within a microcontroller. Physically, timer is aregister whose value is continually increasing to 255, and then it starts all overagain: 0, 1, 2, 3, 4.255.0, 1, 2, 3.etc. The following figure illustrates this.18

PIC Lab ManualMore Information about TMR0This incrementing is done in the background of everything a microcontroller does. Itis up to programmer to "think up a way" how he will take advantage of thischaracteristic for his needs. One of the ways is increasing some variable on each timeroverflow. If we know how much time a timer needs to make one complete round, thenmultiplying the value of a variable by that time will yield the total amount of elapsedtime.PIC16F84 has an 8-bit timer. Number of bits determines what value timer counts tobefore starting to count from zero again. In the case of an 8-bit timer, that number is256. A simplified scheme of relation between a timer and a prescaler is represented onthe previous diagram. Prescaler is a name for the part of a microcontroller whichdivides oscillator clock before it will reach logic that increases timer status. Numberwhich divides a clock is defined through first three bits in OPTION register. Thehighest divisor is 256. This actually means that only at every 256th clock, timer valuewould increase by one. This provides us with the ability to measure longer timerperiods.TMR0 and ResetAfter each count up to 255, timer resets its value to zero and starts with a new cycle ofcounting to 255. During each transition from 255 to zero, T0IF bit in INTCOMregister is set. If interrupts are allowed to occur, this can be taken advantage of ingenerating interrupts and in processing interrupt routine. It is up to programmer toreset T0IF bit in interrupt routine, so that new interrupt or new overflow could bedetected. Beside the internal oscillator clock, timer status can also be increased by theexternal clock on RA4/TOCKI pin. Choosing one of these two options is done inOPTION register through T0CS bit. If this option of external clock was selected, itwould be possible to define the edge of a signal (rising or falling), on which timerwould increase its value.Option Control RegisterBit 0:2 PS0, PS1, PS2 (Prescaler Rate Select bit)The subject of a prescaler, and how these bits affect the work of a microcontroller willbe covered in section on TMR0.bit 3 PSA (Prescaler Assignment bit)Bit which assigns prescaler between TMR0 and watchdog timer.1 prescaler is assigned to watchdog timer.0 prescaler is assigned to free timer TMR019

PIC Lab Manualbit 4 T0SE (TMR0 Source Edge Select bit)If trigger TMR0 was enabled with impulses from a RA4/T0CKI pin, this bit woulddetermine whether it would be on the rising or falling edge of a signal.1 falling edge0 rising edgebit 5 T0CS (TMR0 Clock Source Select bit)This pin enables a free-run timer to increment its value either from an internaloscillator, i.e. every 1/4 of oscillator clock, or via external impulses on RA4/T0CKIpin.1 external impulses0 1/4 internal clockbit 6 INTEDG (Interrupt Edge Select bit)If occurrence of interrupts was enabled, this bit would determine at what edgeinterrupt on RB0/INT pin would occur.1 rising edge0 falling edgebit 7 RBPU (PORTB Pull-up Enable bit)This bit turns internal pull-up resistors on port B on or off.1 'pull-up' resistors turned on0 'pull-up' resistors turned offProcedurePart1: TMR0 Write an assembly program to make a Counter using TMR0; the countershould increment its value on every 2 pushbuttons on RA4.Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulatedProgram a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor.20

PIC Lab ManualPart2: Watchdog Timer (WDT) Write an assembly program to make a Counter using WDT; the countershould increment its value on every one single pushbutton on RA4, and alsocounts from 0 to 99. Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulated Program a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructorPart 2 Present your results in a lab report including a copy of the source codes.21

PIC Lab ManualLab 7EEPROM Memory ApplicationObjectives14. To know what is the EEPROM Memory in Microcontroller PIC16F84A.15. To know how to write to and how to read from this memory.16. To know the advantages of this memory over other memories.ToolsPIC16F84A microcontroller, MPLAB software, PROTEUS software, USBProgrammer.TheoryPIC16F84 has 64 bytes of EEPROM memory locations on addresses from 00h to63h those can be written to or read from. The most important characteristic of thismemory is that it does not lose its contents during power supply turned off. Thatpractically means that what was written to it will be remaining even ifmicrocontroller is turned off. Data can be retained in EEPROM without powersupply for up to 40 years (as manufacturer of PIC16F84 microcontroller n practice, EEPROM memory is used for storing important data or some processparameters.One such parameter is a given temperature, assigned when setting up atemperature regulator to some process. If that data wasn't retained, it would benecessary to adjust a given temperature after each loss of supply. Since this isvery impractical (and even dangerous), manufacturers of microcontrollers PROM memory is placed in a special memory space and can be accessedthrough special registers. These registers are: EEDATA at address 08h, which holds read data or that to be written. EEADR at address 09h, which contains an address of EEPROM locationbeing accessed. EECON1 at address 88h, which contains control bits. EECON2 at address 89h. This register does not existphysically and serves to protect EEPROM from accidentalwriting.EECON1 register at address 88h is a control register with fiveimplemented bits. Bits 5, 6 and 7 are not used, and by readingalways are zero. Interpretation of EECON1 register bits follows.22

PIC Lab ManualEECON1 RegisterBit 0 RD (Read Control bit)Setting this bit initializes transfer of data from address defined in EEADR toEEDATA register. Since time is not as essential in reading data as in writing, datafrom EEDATA can already be used further in the next instruction.1 initializes reading0 does not initialize readingBit 1 WR (Write Control bit)Setting of this bit initializes writing data from EEDATA register to the addressspecified trough EEADR register.1 initializes writing0 does not initialize writingBit 2 WREN (EEPROM Write Enable bit) Enables writing to EEPROMIf this bit was not set, microcontroller would not allow writing to EEPROM.1 writing allowed0 writing disallowedBit 3 WRERR (Write EEPROM Error Flag ) Error during writing to EEPROMThis bit was set only in cases when writing to EEPROM had been interrupted bya reset signal or by running out of time in watchdog timer (if it's activated).1 error occured0 error did not occurBit 4 EEIF (EEPROM Write Operation Interrupt Flag bit) Bit used to inform thatwriting data to EEPROM has ended.When writing has terminated, this bit would be set automatically. Programmermust clear EEIF bit in his program in order to detect new termination of writing.1 writing terminated0 writing not terminated yet, or has not startedProcedure of Writing Operation1.2.3.4.5.6.7.Put the address which you want to write to in EEADR.Put the data which you want to write in EEDATA.Disable all interrupts (GIE 0).Set the bin WREN in EECON1.Put the Keys in EECON2 (first 0X55 then 0XAA).Set the bin WR in EECON1.Wait until Writing Operation is finished.23

PIC Lab Manual8. Enable all interrupts.Procedure of Reading Operation1. Put the address which you want to read from in EEADR.2. Set the bin RD in EECON1.3. Move the read data from EEDATA to the work register.We follow these procedures in all times we want to write to or read from EEPROMMemory, except that the address which we want to write to in writing operation /orread from in reading operation; and the data which we want to write in writingoperation/ or read in reading operation differ each time.ProcedurePart1: Write an assembly program to fill all the EEPROM Memory locations With7.Hint // Build an external Macro called EEPROM Writing takes twoparameters the data and the address to achieve the writing operation; thencall it in the main program. Simulate your program using the software PIC Simulator IDE.Part2: Write an assembly program to take the data existed on PORT A and display iton PORT B; first, the data must be taken from PORT A and stored in theEEPROM address location 0X10, and then be taken again from EEPROMand be displayed on PORT B. You should use the EEPROM Writing Macro from the previous part forwriting operation, and also build a nother macro EEPROM Reading forreading operation.Simulate your program using the software PIC Simulator IDE.Simulate the program using the circuit shown in figure via Proteus software.Verify it operates properly when simulatedProgram a PIC 16F84A using the QL2006 programmer.Build the circuit using the programmed PIC 16F84A and then observe itsoperation. Demonstrate the circuits operation to the instructor 24

PIC Lab ManualPart 3 Present your results in a lab report including a copy of the source codes.25

PIC Lab ManualLab 8Introduction to MikroC LanguageObjectives17. To know what is the MikroC Language.18. To know how to write your first program in MikroC Language.19. To know the advantages and disadvantages of this language over AssemblyLanguage.ToolsPIC16F84A microcontroller, MikroC software, PROTEUS software, USBProgrammer.TheoryMikroC is a powerful, feature rich development tool for PICmicros. It is designedto provide the programmer with the easiest possible solution for developingapplications for embedded systems, without compromising performance orcontrol.PIC and C fit together well: PIC is the most popular 8-bit chip in the world, usedin a wide variety of applications, and C, prized for its efficiency, is the naturalchoice for developing embedded systems. MikroC provides a successful matchfeaturing highly advanced IDE, ANSI compliant compiler, broad set of hardwarelibraries, comprehensive documentation, and plenty of ready-to-run examples.Features of MikroCMikroC allows you to quickly develop and deploy complex applications: Write your C source code using the built-in Code Editor (Code and ParameterAssistants, Syntax Highlighting, Auto Correct, Code Templates, and more )Use the included MikroC libraries to dramatically speed up the development:data acquisition, memory, displays, conversions, communications Practically all P12, P16, and P18 chips are supported.Monitor your program structure, variables, and functions in the CodeExplorer.Generate commented, human-readable assembly, and standard HEXcompatible with all programmers.Inspect program flow and debug executable logic with the integratedDebugger.Get detailed reports and graphs: RAM and ROM map, code statistics,assembly listing, calling tree, and more There are plenty of examples for you to expand, develop, and use as buildingbricks in your projects. Copy them entirely if you deem fit – that’s why weincluded them with the compiler.26

PIC Lab ManualCompilation and AssemblingAs shown MikroC code needs two steps to be transformed to Machine code, thefirst step is to transform the C code to Assembly code, which is calledCompilation.The second step is to transform the Assembly code to Machine Code, and thi

2. From the project menu choose project wizard. 3. Choose PIC 16F84A. 4. Brows and name the project. 5. From view menu choose project; to view the project. 6. Then add a file to the source files by right clicking on source files, and choose add files and then name the file anyName.asm.