Loading...
Pic Programming

Pic Programming Techniques.

Programming Techniques.

Before programming the PIC, I think now is a good time to explain some programming techniques.

If you type a ; (semicolon) anywhere in your program, the compiler will ignore anything after it until the carriage return.  This means we can add comments in our program to remind us of what on earth we were doing in the first place.  This is good practice, even for the simplest programs.  You may well fully understand how your program works now, but in a few months time, you may be scratching your head.  So, use comments wherever you can – there is no limit.

Secondly, you can assign names to constants via registers (more about these later).  It makes it far easier to read in English what you are writing to, or what the value is, rather than trying to think of what all these numbers mean.  So, use real names, such as COUNT.  Notice that I have put the name in capitals.  This makes it stand out, and also means that (by convention) it is a constant value.

 

Thirdly, put some kind of header on your programs by using the semi-colons.  An example is below:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Author :                                                                     ;
; Date :                                                                        ;
; Version:                                                                    ;
; Title:                                                                          ;
;                                                                                   ;
; Description:                                                             ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;                                                                                   ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

Notice that I have made a kind of box by using the semi-colons.  This just makes it look neat.

 
Finally, try and document the program on paper as well.  You can either use flow charts or algorithms or anything else you want.  This will help you in writing your program, step by step. Right, that’s the lecture over with, lets move on to the real stuff.


Keywords : Pic6f84, Pic, Introduction, What Are PICs, Insruction, Set, Assembler
Writer : delon  |
19 Feb 2006 Mon   
|  5.305 Views
No Comments
Write Comment
Your Name
Email
You are writing as anonymous comment, if you are a member please login.