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.

I'm new and need a little guidence. LED Blink pic16f877

Status
Not open for further replies.

modsbyus

Newbie level 1
Joined
Jan 27, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
This is my code. I can't seem to get the led to blink. Would someone please help? I don't just need it to work, I need to understand why it doesn't work.
Thank you.

Code:
        LIST P=16F877,W=-302
        INCLUDE "P16F877.INC"
        __CONFIG 0x3D32 ; HS MODE,WDT OFF

        cblock
	d1
	d2
	d3
	endc


        ORG     0X0000      ;Program starts at address zero.
        NOP
MAIN
        BANKSEL PORTA       ;Select PORTA
        MOVLW   B'00000000' ;Reset PORTA
        MOVWF   PORTA
        BANKSEL TRISA       ;Select bank one
        MOVLW   B'00000000' ;Make PORTA all outputs
        MOVWF   TRISA
        BANKSEL PORTA
                            ;Delay of 2499999 cycles
	movlw	0x16
	movwf	d1
	movlw	0x74
	movwf	d2
	movlw	0x06
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0

			;1 cycle
	NOP
        BANKSEL PORTA       ;Select PORTA
        MOVLW   B'00000000' ;Reset PORTA
        MOVWF   PORTA
        BANKSEL TRISA       ;Select bank one
        MOVLW   B'11111111' ;Make PORTA all inputs
        MOVWF   TRISA
        BANKSEL PORTA

        GOTO    MAIN        ;Loop to address "MAIN"
        END
 

You are not actually putting anything on to the out pins, you are just changing their status from output to input.

Check on this page and try to understand how it works from there, it should help PIC Tutorial One - LED's
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top