[SOLVED] need help with my 1st led project

Status
Not open for further replies.
Hi,

Its a great feeling when you get you first project working.

The code I use is called Assembly, a very Low level language where you have to tell it line by line what to do; its very different to High level languages like C.

Here is my 'flasher' code, you use it with the Assembler program built in to Mplab.

Code:
;       specify basic chip information and Configuration

		list p=16f877a
		include p16f877a.inc
		__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _PWRTE_ON & _LVP_OFF


; 		set up user variables / registers/ work files
	
		cblock 0X30
		d1
		d2
		d3
		COUNT
		endc


;       start of program code


		org 	0x00
		GOTO	Main
	
		org		0x04
		RETFIE


;       set up the i/o port for your needs


Main	CLRF	PORTB		; SET portb,c,d to outputs
		CLRF   	PORTD
		CLRF 	PORTC
		BANKSEL TRISA
		CLRF	TRISB
		CLRF 	TRISC
		CLRF 	TRISD
		BANKSEL 0

;       the 'actual' program loop

loop	bsf		PORTB,0
		CALL 	DELAY1
		bcf		PORTB,0
		CALL 	DELAY1
		GOTO	LOOP		



	


;      the Called Subroutine,  Delay = 1 seconds = 1000000 cycles with a 4Mhz oscillator
DELAY1
		movlw	0x08
		movwf	d1
		movlw	0x2F
		movwf	d2
		movlw	0x03
		movwf	d3
Delay_0
		decfsz	d1, f
		goto	$+2
		decfsz	d2, f
		goto	$+2
		decfsz	d3, f
		goto	Delay_0


		return

		END
 
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating

think you i try to know more there

- - - Updated - - -


think you for the code and every thing you really helped
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…