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.

PIC18F8720 proteus and mplab

Status
Not open for further replies.

microeus

Newbie level 1
Joined
Mar 16, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
Hi. I'm new to assembly language.I'm doing running light using 25 leds and pic18f8720. Testing on proteus. I'm unable to make it work.

Kindly see the attached source code and proteus dsn file. Hope someone can correct my mistakes here.

Using INT0 as reset interrupt.
Timer delay is 1 sec.



Source asm, hex and dsn files here:
**broken link removed**

Thank you.

circuit.jpg


#include<p18F8720.inc>

org 0X00
goto start
org 0X08
goto ISR_timer
org 0X18
goto ISR_reset
retfie

start setf TRISB;
clrf TRISD;
clrf TRISE;
clrf TRISF;
clrf TRISH;
clrf TRISJ;
BCF RCON,IPEN, A;
BSF INTCON,GIEH,A;
BSF INTCON,INT0IE;
goto patt1;

patt1 movlw B'00010101';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
clrf WREG;
movlw B'00001010';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
BTFSS PORTB,2,A;
goto patt1;
goto patt2;
patt2 movlw B'00011001';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
clrf WREG;
movlw B'00000110';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
BTFSS PORTB,2,A;
goto patt2;
goto patt3;
patt3 movlw B'00000111';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
clrf WREG;
movlw B'00011000';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
BTFSS PORTB,2,A;
goto patt3;
goto patt4;
patt4 movlw B'00000111';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
clrf WREG;
movlw B'00011000';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
BTFSS PORTB,2,A;
goto patt4;
goto patt5;
patt5 movlw B'00000111';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
clrf WREG;
movlw B'00011000';
movwf PORTD,A;
movwf PORTE,A;
movwf PORTF,A;
movwf PORTH,A;
movwf PORTJ,A;
CALL ISR_timer;
CALL ISR_reset;
BTFSS PORTB,2,A;
goto patt5;
goto patt1;

ISR_reset BTFSS PORTB,1,A;
goto patt1;
return;


ISR_timer BCF T0CON,PSA;
BSF T0CON, 0;
BSF T0CON, 1;
BSF T0CON, 2;
MOVLW 0XB3;
MOVWF TMR0H;
MOVLW 0XB4;
MOVWF TMR0L;
BCF INTCON, TMR0IF;
BSF T0CON, TMR0ON;
BTFSS INTCON,TMR0IF;
RETURN;
END
 

Hi,

To make it work you need to add a 10K resistor between +20v, which should be shown as +5v, and pin 9 Mclr /Vpp - then it runs.

That code is a fine example of how NOT to code in Assembler - hope you are not trying to learn from it.

If you want to code Assembler correctly - this is a good place to start.
Nigel's PIC Tutorial Page
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top