Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine. (Nikola Tesla)

19/06/2010

●Getting started to PIC Programming 1

♦What is PIC?

Before starting to introduction, I firstly explain what the PIC is. PIC is the name of the microcontrollers produced by Microchip Technology. You can see it here. There plenty of models of microcontrollers such as PIC16F628A and PIC16F877. But in my introduction, I will talk about PIC16F628A cause it has an internal oscillator runs at 4MHz. So, we need no more crystal setting.

♦What can we do with the microcontrollers?

Actually, the name of the microcontroller simply contains the answer of this question. Microcontrollers are the ones that controls required operations in a automatically controlled system. In simple terms, we can make robots, remote control systems and even a sign board with 7-segment-display by the aid of microcontrollers.

♦How is the architecture of PIC16F628A?

If you want to have a PIC to work, you need to program it. So, the software in it is essential. Two other essential things for a PIC are the power supply and the oscillator. We have an internal oscillator in PIC16F628A, so we don’t need any external oscillator such as crystal. Also these microcontrollers have 18 pins. Two pins are related to power supply pins named as VDD (which should be connected to positive power supply) and VSS (which should be connected to negative power supply or 0V). Other 16 pins are input/output pins. MCLR pin is used when we want to re-program the PIC and, normally it is connected to positive supply. INT pin is used to restart to program and the program restarted if it is high. RA is a 5-bit bidirectional port, so the pins RA0 to RA4 can be configured as an input or output. Also RB is a 8-bit bidirectional port, and the pins RB0 to RB7 can be configured as input and output pins. Also the detailed information can be learned from the datahsheet of the manufacturer.

♦What are the essential tools to get started programming?

Firstly, a kind of PIC microcontroller is needed for programming and I will talk about PIC16F628A. Also you need to choose alternatively which programming language you will use for the coding, then you need to have a compatible compiler to convert the program,that you write, into .hex formatted file that the PIC understands. The other thing is a PIC Programmer and the software provided with it. PIC programmer is used to program the PIC with the compatible software. To put it clearly, you write a program in any programming language, you get an .hex file by compiling with the compiler, then, by the aid of the software and PIC programmer you can program your PIC using this .hex formatted file.

♦Which programming language can we use?

You can alternatively choose a language among the plenty of programming languages. PIC C (contains the languages like CCS C, HI-TECH C), PIC Basic and PIC Assembly are the options available. But PIC Assembly is a little bit different. Actually, it is the language that the manufacturer of PIC (Microchip) developed as fundamental software language. It is a little difficult and slow to create your program with assembly language because of using a lot of common commands of language. But, you have the opportunity to learn the programming structure intimately. Also, when you choose PIC Assembly, you need to have a PIC Assembler to convert the codes into machine code (.hex code). You can get MPLAB provided with mpasm which is an assembler. MPLAB is a well-known program to write programs in assembly, compile them and find the errors in it. Also, you can use its feature to find the error, if you use another compilers like CCS C. You can download this freeware program from the site of Microchip.

ShareThis