PDA

View Full Version : My PIC program won't work! Plz Help?!



beckyzammi
- 4th March 2010, 17:45
Hey guys, i wrote a program in assembly for the 80C51 and it worked but now i have to write the same one for the PIC16F84A in assembly language, and it just wont work. Can someone figure out what mistakes i did?
This program controls one 7-segment display to count from 0-9 whilst the other 7-segment display to count from 9-0 at the same time.
Thanks for any help.

LIST P=16F84
INCLUDE "P16F84.INC"
__CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
RADIX HEX
;
PORTB EQU 0x06
PORTA EQU 0x05
;
R1 EQU 0x0C
R2 EQU 0x0D
R3 EQU 0x0E
;
ORG 0
;
MOVLW 0x1F
TRIS PORTA
;
MOVLW 0x00
TRIS PORTB
;
CLRF PORTA
CLRF PORTB
;
REPEAT: MOVLW 0x0F
MOVFW PORTB
;
MOVLW 0x0F
MOVFW PORTB
;
PA_0: BTFSC PORTA,0
GOTO PA_0
;
CALL DISP
BTFSC PORTA,0
GOTO PA_0
;
MOVLW 0x06
MOVFW PORTB
MOVLW 0xF6
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xDA
MOVFW PORTB
MOVLW 0xFE
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xF2
MOVFW PORTB
MOVLW 0xE0
MOVFW PORTB
;
CALL DISP
;
MOVLW 0x66
MOVFW PORTB
MOVLW 0xBE
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xB6
MOVFW PORTB
MOVLW 0xB6
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xBE
MOVFW PORTB
MOVLW 0x66
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xE0
MOVFW PORTB
MOVLW 0xF2
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xFE
MOVFW PORTB
MOVLW 0xDA
MOVFW PORTB
;
CALL DISP
;
MOVLW 0xF6
MOVFW PORTB
MOVLW 0x60
MOVFW PORTB
;
CALL DISP
;
GOTO REPEAT
;
;
DISP: MOVLW 1
MOVFW R3
LP3: MOVLW 0x0F
MOVFW R2
LP2: MOVLW 0x0F
MOVFW R1
LP1: DECFSZ R1
GOTO LP1
DECFSZ R2
GOTO LP2
DECFSZ R3
GOTO LP3
;
RETURN
;
END
;
;At blast time, select:-
;
;memory unprotected
;watchdog timer disables
;standard crystal (4MHz)
;power up timer on

Acetronics2
- 4th March 2010, 18:20
Hi, Zammi

first : note here is NOT the best place to ask about Assembler ... much better about PicBasic ... !!!

with my limited skills, ...

I really wonder what you try to do with all those lines groups ... :



MOVLW 0x06
MOVFW PORTB
MOVLW 0xF6
MOVFW PORTB


Alain

beckyzammi
- 4th March 2010, 18:26
the aim of my project was to change the 80C51 code program into the PIC assembly language..the original program in assembly language og the 80C51 was this:

dis1 equ P1.0
dis2 equ P1.1
;
org 00h
ljmp main

org 30h;
main: mov r2,#0FCh
mov r3,#0FCh
acall disp
mov r2,#060h
mov r3,#0F6h
acall disp;
mov r2,#0DAh
mov r3,#0FEh
acall disp;
mov r2,#0F2h
mov r3,#0E0h
acall disp;
mov r2,#066h
mov r3,#0BEh
acall disp;
mov r2,#0B6h
mov r3,#0B6h
acall disp
mov r2,#0BEh
mov r3,#066h
acall disp;
mov r2,#0E0h
mov r3,#0F2h
acall disp;
mov r2,#0FEh
mov r3,#0DAh
acall disp;
mov r2,#0F6h
mov r3,#060h
acall disp;
sjmp main;

disp: mov r4,#0ffh;
loop: mov r5,#0f0h;
loop1: mov a,r2;
clr dis2;
cpl a;
mov P2,a;
setb dis1;
nop;
nop;
mov a,r3;
clr dis1;
cpl a;
mov P2,a;
setb dis2;
djnz r5,loop1;
djnz r4,loop;
clr dis1;
clr dis2;
ret;
end