Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Light 1 LED!

Status
Not open for further replies.

Squintz

New Member
Can somone post a schematic and code for making a PIC16f84a light 1 LED and turn it off again. Or something similar. I Finally have all the stuff i think i need to program a pic and i had built a circuit and programed my pic with agiven code from a web site tutorial but it does nothing.

So i want something very simple and basic so that i can verify that my software and programmer and PICS that i have are working.

From there i will learn how to write code and design circuits on my own but it kind of hard to get into writing code and making circuits if your not sure the parts you have are working from the start.

Thanxs for any help
 
Thanx for the site but i want something much mor simple. Least amount of components and only a few lines of code.

I first have to learn how to use my programming software before i can venture out to the bigger things.

Baby Steps
 
Code:
	LIST P=16F84A	
	#include <P16F84A.INC>

	ERRORLEVEL -302		;suppress bank selection messages

	CBLOCK	0x0C		  ;block of variable defenitions, starting at memory adress 0x0c 
	Loop1				    ;The pic16F84A's RAM starts at this adress (see datasheet)
	Loop2
	Loop3				    ;all counters for the delay loop
	ENDC				     ;variables end

	ORG	0x00			  ;program entry adress

	BANKSEL	TRISB		;go to memory bank 1 for loading TRIS values
	BCF		TRISB, 0	 ;clear TRISB, bit 0 -> makes PORTB bit 0 an output (for the led)
	BANKSEL	PORTB		;back to bank 0

MainLoop				    ;this part will be repeated over and over and ...

	BCF		PORTB, 0	 ;make the led pin low (led will light)
	CALL	Delay		   ;and call the delay
	BSF		PORTB, 0	 ;make the led pin high (led will go out)
	CALL	Delay		   ;and wait again
	GOTO	MainLoop	   ;back to beginning

Delay	;the delay routine

	MOVLW	0x10
	MOVWF	Loop1		;put 10h in loop1

Reload_Loop2
	MOVLW	0xFF
	MOVWF	Loop2		;put FFh in Loop2

Reload_Loop3
	MOVLW	0xFF
	MOVWF	Loop3		;put FFh in Loop3

	DECFSZ	Loop3, F  ;subtract 1 from loop3, skip next instruction if result = 0
	GOTO	$-1			;go back 1 instruction 
	
	DECFSZ	Loop2, F
	GOTO	Reload_Loop3	;if not 0, then reload loop3

	DECFSZ	Loop1, F		;if not 0, then reload loop2
	GOTO	Reload_Loop2

	RETURN
		
	END
 

Attachments

  • F84LEd.JPG
    F84LEd.JPG
    33.5 KB · Views: 941
isnt there any other way to get a simple circuit like that to flash an led?

like instead of using a crystal cant you simply use a capacitor of some sort?

Kane
 
Yes, you can use an RC osc.

Connect the Resistor to VDD , other side to the Capacitor and the capacitor to GND. Connect the CLockIN from your pic between the R and the C

I often use 470K with a 22pf cap

Don't forget to program the pic with RC osc. in the config word.
 
Hello all,
Slightly off topic - a question for EXO. What software do u use for your circuit diagrams ie the circuit posted on this page. Thank you.
Barry.
 
wooooo :D

i had a few other kits which were for the 16f84A and they had a test ciruit on em ....i forgot all about it

it has an inbuilt oscillator and everything (doh)

but im happy now as i know everything works :)
can get onto learning assembly :?

Kane
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top