Pic tutorial :: Writing a program

Writing a program

Only after all of the preceding operations have been completed we are able to start writing a program. This sample program is fairly simple and serves to illustrate creation of a project.

    AUTHOR : romux team     */ 
        PROCESSOR   16f84 
        #include "P16F84.inc"        
        __CONFIG  _CP_0FF  &   _WDT_0FF  &   _PWRTE_0N  &  _XT_0SC        
        CBLOCK 0x0C                  ;RAM starting address 
                                      ;Auxiliary variables   for  macro  pausems     
            ORG    0X00                ;Reset vector
            GOTO    MAIN
            ORG    0X04                ;Interrupt vector
            GOTO    ISR             ;no   interrupt routine

        INCLUDE    "ROMUX_LIB.INC"        
MAIN                                ;Main program        
            BANKSEL TRISB           ;Select bank containing TRISB 
            CLRF        TRISB       ;Port B   is   output 
            BANKSEL  P0RTB          ;Select bank containing P0RTB        
            MOVLW   0X00           ;Sraitch off  diodes  on port B 
            MOVWF    P0RTB 
            PAUSEMS   .500          ;500ms  delay   (0.5sec) 
            MOVLW   OXFF            ;Switch  on  diodes  on port B 
            MOVWF    P0RTB 
            PAUSEMS   .500          ;500ms   delay   (0.5sec) 
            GOTO      LOOP          ;Jump  to  label  Loop        

You should re-write the program to the newly opened window or just copy/paste it from the disk.

Main window with blink.asm program

When the program is copied to "Blink.asm" window, we can use PROJECT -> BUILD ALL command to translate the program to executable HEX form. The last sentence in the window is the most important one, because it shows whether translation was successful or not. "BUILD SUCCEEDED" is a message stating that translation was successful and that there were no errors.

In case that error does show up, you need to double click on error message in 'Output' window. This will automatically take you to the assembler program, to the line where the error was encountered.


Post Your Comments Here :

User Login

Username :

Password :