[Menu]>[Guide to use the PIC]


About the software


PIC can do various operation by executing the instructions which were stored in the program memory(PM).
The instruction which is stored at the head(0000h) of PM is executed when turning on the power. If GOTO instruction is stored there, the PIC changes the execution address of the program according to the contents of the instruction.

To make software is to make the order of the operation to make PIC do. Therefore, it is necessary to decide what operation you want to make the PIC.
For example, it makes an LED blink, it makes judge the condition of the input or it lets out a specific signal...

To think of the order of the instruction is software creating.



I will explain the following example for you to understand software creating easily.

    Job of the PIC
      Count-up the content of the specific address of the memory.
      (Only in this processing, it is empty but it is simple example.)

    Condition
      The memory to count-up is the 0Ch address of the RAM file register.

    Processing flow
      The processing immediately after the turning on starts from address 0 of the PM.
      In the actual program, the initialization processing is necessary. However, in the example this time, it is omitted.
PM addressProcessing contentsInstructions



0000hClear the contents of the 0Ch addressCLRF
0001hIncrement the contents of the 0Ch addressINCF
0002hJump to 0001hGOTO


    The contents which are written at the PM are as follows.
PM addressMemory contentsComments



0000h The red part shows CLRF instruction.
The green part shows the file register address.
0001h The red part shows INCF instruction.
The blue part shows to store a processing result in the file register.
The green part shows the file register address.
0002h The red part shows GOTO instruction.
The green part shows a program address.


    The PIC does following operation when writing contents like the above in the 3 words from the head of the PM and turning on the power.
    First, the 0Ch address of the file register is cleared in address 0 of PM and count-up in address 1 of PM. Next, the GOTO instruction is executed in address 2 and jumps to address 1. Then, it repeats the operation to count-up again. This processing doesn't end until it switches off the power.

    PIC recognizes the combination of "0" and "1" which was written in the PM as the instruction. The instruction which was expressed by the combination of "0" and "1" is called machine code. At the digital computer, machine code is always used. Machine code is used for the personal computer which you are using, too. However, the contents of the machine code depend on the processor. Therefore, the Pentium doesn't work by the machine code for PIC.

    I did contents above by the hand computation. However, it is difficult to do in the hand computation when the number of the processing(Step) increases.
    Therefore, the soft development tool which is called the assembler or the compiler is used for the software creating. These tools are the one to make it easy for the person to make software.
    The instruction can be expressed by the character. It is possible to use a character string(Label) when specifying the address of the memory. So on.
    Also, when working the same software in the hardware which the machine code is different from, it is sometimes possible if changing only machine code. In the such case, because the assembler or the compiler changes into the machine code which suited the hardware automatically, the person has the advantage that he can make software without being conscious of the machine code, too.

    It is as follows when changing above-mentioned processing into the machine code automatically using MPASM(Assembler) of the Microchip Inc..
    The input file for the assembler(Source code) is made with Editor. The person makes this source code. This work is called CODEING.

The Source Code
                LIST            P=16F84A
                ORG             0
                CLRF            0C
LOOP            INCF            0C,1
                GOTO            LOOP
                END

I am using a hexadecimal number for the specification of the address(0Ch) of the file register. Because the default is a hexadecimal number in MPASM, it is handled with the hexadecimal number when writing just as it is. It's OK even if you write H'0C'.
When writing in the decimal number, it is written as D'12' or .12 (dot 12).
When writing in the binary number, it is written as B'1100'.


The Listing File
LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001                 LIST            P=16F84A
0000                  00002                 ORG             0
0000   018C           00003                 CLRF            0C
0001   0A8C           00004 LOOP            INCF            0C,1
0002   2801           00005                 GOTO            LOOP
                      00006                 END

The LOC column shows the program memory address.
The OBJECT CODE column shows the machine code.
You find that it becomes the contents which are the same as the one by the hand computation.