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.

Problem with LED flashing program in MPLAB

Status
Not open for further replies.

williamchia

Newbie level 6
Joined
Jan 19, 2007
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,390
Hi all,

For half month, i have been trying to write a simple program using MPLAB to make the LEDs flash but not working. Have been checking and trobleshooting upside down, left to right but still dunno what is the problem..

Then i down-grade to just making the LED light up (I'd be very happy even for that) but it is still not working ...8O

;**********************************************************
;* LED Flashing
;**********************************************************

list p=16f877A

; Include file, change directory if needed
include "p16f877A.inc"


; Start at the reset vector
org 0x000
nop
Start


banksel TRISB
clrf TRISB ;set PORTB to output
banksel PORTB

Main

movlw 0xff
movwf PORTB ;turn on LEDS on PORTB
nop
nop
movlw 0x00
movwf PORTB ;turn off LEDs

end



No errors on build all and assembly. Wish some1 could point out what goes wrong.

The circuit is at URL:

Thank you very much.

Regards,
William
 

Re: Desperate

Hello William,
In your programs MAIN routine you set PORTB high to turn on your led's then you are only waiting 4 instruction cycles and then turning them off again. with a 20 Mhz clock you will never see the very short flash. Also after you turn off the led's, your program just goes off into neverland, The END directive does not stop the processor it will keep trying to execute the rest of the instructions in the program space. which is empty.

You need to make your program follow something like below.

1. Turn on led's

2. Wait long enough to see them.

3. Turn off led's

4. Wait again

5. Go back to No. 1
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top