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.

[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
 
  • Like
Reactions: hesho90

    hesho90

    Points: 2
    Helpful Answer Positive Rating
Some Proteus devices, including the PIC microcontrollers, have both Vdd and Vss hided by default. However, there is a setting under the devices properties which displays these pins if desired. I should also mention both OSC1 and OSC2 are essentially nonfunctional, meaning the crystal and capacitor pairs do not have to be proper attached for the simulation to function properly. However, the oscillator/clock frequency must be properly set/configure under the device properties for the simulation to perform as expected.

It should be noted this is NOT the case with all microcontroller simulations in Proteus, designs with ARMs require both the Vdd, Vss and Oscillator/Clock source be properly attached in the design for the simulation to function as expected.



Do you not understand the function or location of pins of the PIC?

As wp100 suggested, I would study the Gooligum Tutorials:

**broken link removed**

While the tutorials utilize a different version of PIC, the concepts are generally the same and can be easily applied to the PIC16F877A, which is considered a Midrange PIC by the way.

BigDog

think you i try to know more there

- - - Updated - - -

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

think you for the code and every thing you really helped
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top