This is your first program

 

HELLO WORLD

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 “p16f84.inc”
org 0x00
goto start
org 0x20
start
bcf INTCON,7
movlw 0x00
bsf STATUS,5
movwf TRISB
bcf STATUS,5
again

movlw 0x80
movwf PORTB

call delay

movlw 0x00
movwf PORTB

call delay

goto again

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

;*********************************************************************

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 Assemle.

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 …

Be the first to comment

Leave a Reply

Your email address will not be published.


*