How to write a code for PIC microcontrollers ?
If above question is in your mind then this Tutorial will help you in understanding the steps involves in writing a code for micro controllers , developing an electronic circuit and completing a project. We will call the electronics applications using microcontrollers and microprocessor as main processing IC unit as Embedded system. There are several definitions are available on Internet. But in simple words The Embedded system are those which use microcontroller as central processing device and some peripheral components are attached to complete the task.
Embedded system design is made up of two main aspects:
- The hardware
- The software.
In the early days of microprocessors and microcontrollers, The Embedded systems were designed and built up using a large number of integrated circuits (ICs). There were many limitations with those, one of the important is : Memory was very limited, so only small programs could be written.
But now the available ICs are more sophisticated and have enough memory to cope up memory issues. Now the designer had to do less to get a working hardware system.
With the advancement in IC fabrication technology, the complex hardware systems can be built up with comparative ease, and in many projects software development is now the main creative activity.
Thus our main focus will be on programming side. For learning purposes , it is always recommended that one should start with the Assemble programming language.
The embedded systems programs are written to run on a target system which is micro-controller in our case. You may be working with an educational PIC hardware system which will use PIC-16f877 and some other ICs attached with microcontroller.
we will use the Microchip MPLAB Integrated Development Environment, and the simulator in it.
What Programs Do and How We Develop?
The main ideas of computer programming may be many, but some of them are listed as under:
- A computer or microcontroller or microprocessor (any of these) has an instruction set. This set of instruction is the basics of programming. Once we select the device (microcontroller) to use and write a program for it, then the first job is find its Instruction set and understand it.
- The microcontroller can recognize each instruction and execute it, if it is properly used.
- The program that the microcontroller executes is a list of instructions drawn from its instruction set.
- It reads these in binary from its program memory. The program in this form (converted into binary language ) is also called machine code.
- To execute the program, the microcontroller works relentlessly through the instructions of the program, from the beginning to end.
- The microcontroller is ruthlessly logical and does exactly what it is told.
The Process of Writing in Assembly language program for microcontroller:
The programmer writes an assembly language program by using nothing more than a text editor. This process of writing code for microcontroller on a computer is often termed as the cross-assembler. The terminology cross-assembler implies that one computer is assembling code for one of another type, not for itself. Mostly the cross-assembler is shortened simply to assembler. The main job of cross-assembler is to assemble the program just written by programmer. This process is explained as, cross-assembler converts the program from assembler mnemonics into machine code ready to use for the microcontroller.
The Program Development Process:
The Program Development Process is consisting of following steps:
1. Write source code:
The programmer writes the program, called the source code, in Assembler language.
This is then assembled by the cross-assembler running on the host computer.
This is an optional step, if the programmer or user have a good simulator program installed on his/ her computer, then he/ she can simulate the code and if errors are in logic then these can be remove with making corrections in the source code.
4. Hex file Downloading:
When satisfi ed with the program, the developer will then download it to the program memory of the microcontroller itself by using a suitable hardware ( a stand-alone “programmer”) or universal programmer the hex file can be downloaded to the microcontroller, this process is also called burning of code into microcontroller.
5. Test in hardware:
The last stage is to test the program running in the actual hardware. This is likely to lead to program errors being discovered. Again, this may lead to changes being required in the source code.Tags:-pic programming pdf,pic microcontroller programming,pic microcontroller,pic programmer,pic projects,pic tutorial,pic programming software,pic programming for beginners,pic programmer software,pic 16c84,Parallel Port PIC Programmer ,PonyProg - Serial device programmer,Microchip PIC programmer Serial & USB,The Basics of Programming and Using a PIC Microcontroller,Free PIC programming software, Microcontroller Technology,WinPicProg Page,PIC, AVR, SX, 24Cxx PROGRAMMER,microEngineeringLabs, Inc. | In Circuit Serial Programming with EPIC,PICPgm - A free and simple PIC Development Programmer for Windows