Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Assembly Language for PIC16f877a

Status
Not open for further replies.

onionzai

Newbie level 1
Joined
Dec 8, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Malaysia
Activity points
1,291
Dear all pros, i am currently using assembly language for my Final Year Project. Then i use MPLAB to convert the assembly code to hex code and download it into my Microcontroller using PICkit 2 v2.55. However, it didnt works well for me.

Currently im still testing everything using 2 LED.

This is the code.

list p=16F877,f=inhX32, x=on
#include <p16f877.inc>
errorlevel 0,-302 ;eliminate bank warning

__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF & _LVP_OFF

cblock 0X20

count1
count2
count3

endc

status equ 03h
trisb equ 86h
portb equ 06h

org 0x00

bsf status, 5
movlw b'00000000'
movwf trisb
bcf status, 5


start
movlw b'10010000'
movwf portb
call delay
movlw b'00000000'
movwf portb
call delay
goto start


delay
loop1 decfsz count1, 1
goto loop1
decfsz count2, 1
goto loop1
decfsz count3, 1
goto loop1
return


end


I have uploaded the picture of topview of the circuit. Hope you pros can help me out ! :D
 

Change
Code:
list p=16F877,f=inhX32, x=on
#include <p16f877.inc>
to
Code:
list p=16F877a,f=inhX32, x=on
#include <P16f877A.inc>
Then you don't need to declare status and the other SFRs, only write them in upper case.
Code:
list p=16F877a,f=inhX32, x=on
#include <p16f877a.inc>
errorlevel 0,-302 ;eliminate bank warning

__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF & _LVP_OFF

cblock 0X20

count1
count2
count3

endc

org 0x00

bsf STATUS, 5
movlw b'00000000'
movwf TRISB
bcf STATUS, 5

movlw 0xaa
movwf count1
movwf count2
movwf count3

start
movlw b'10010000'
movwf PORTB
call delay
movlw b'00000000'
movwf PORTB
call delay
goto start


delay
loop1 decfsz count1, 1
goto loop1
decfsz count2, 1
goto loop1
decfsz count3, 1
goto loop1
return

end
You forgot to load the count registers. Load them as required as test.
Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top