Wednesday, December 10, 2008

This is your first PIC16f84A program


As in PC programming world, when you learn a new language , you start with the famous
"Hello World" program.

This program in Microcontroller is flashing a LED.

Here is the code:

; Flasher.asm

list p=16f84 ; This is how you can comment
include ""
org 0x00
goto start
org 0x20
bcf INTCON,7
movlw 0x00
bsf STATUS,5
movwf TRISB
bcf STATUS,5

movlw 0x80
movwf PORTB

call delay

movlw 0x00
movwf PORTB

call delay

goto again

movlw 0x01
movwf 0x0e
movlw 0xfa
movwf 0x0d
movlw 0xfa
movwf 0x0c
decfsz 0x0c,1
goto loop1
decfsz 0x0d,1
goto loop2
decfsz 0x0e,1
goto loop3


1 - Copy the above text and paste it in an empty text file and save it as Flasher.asm

2 - Install the MPLab program and search for the file MPASMWIN.EXE in its path.

3- Run the program. It looks like this :

Uncheck the case-sensitive option.

4 - Browse for the Flasher.asm file and press Assemble.

If every thing goes write , you will have the window :

Congratiulations, the assemble process is complete !!
The Flasher.hex file will be generated in the same directory of Flasher.asm

Note : If you like this blog ( or don't ) , please give me feedback by commenting. Thanks ...

If you like this blog you can support us by many ways:
   1. Leave comments stating your point of view about this article.

   2. Buy our book on Amazon Learn By Making.

   3. Click on links of our sponsors without adding any extra cost on you if you make purchase from them. Actually, many of these offers are totally free.
  4. Visit our new website

Thank you for visiting our blog.

No comments: