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] help pic16f877a programming tutorial using pickit 2

Status
Not open for further replies.

luigi_moran23

Newbie level 5
Newbie level 5
Joined
Mar 4, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,365
Please help me in programming my pic16f877a. I am having hard time working on the hardware part. The software was correct because it was running in the simulation in PROTEUS. Please give me a circuit for burning or sample assembly program for just a simple output to see if my pic16f877a still working. In pickit 2 program, I can read the microcontroller and then write the program to it but my problem is when I put source voltage to it the LED is not LIGHTING up. here is my code:

#include "p16f877.inc"

__CONFIG _CP_OFF & _WDT_OFF& _PWRTE_ON & _XT_OSC

org 0x00 ;reset memory

Main:
; select BANK1
org 0x00 ;reset memory
bsf STATUS, RP0
;bcf STATUS, RP1
; set port c as output
movlw b'00000000'
movwf TRISC ;tris C
;movlw b'11111111'
;movwf h'85'
; select bank 0
bcf STATUS, RP0
bcf STATUS, RP1
; turn on LEDs
LOOP:
movlw b'11111111'
movwf PORTC ;port C
goto LOOP
end


PLEASE help me with it. It will also be the one that will control my quadcopter. Thank you for your help.:)
 

All that boils down to:

banksel TRISC
clrf TRISC
banksel PORTC
LOOP:
movlw 0xFF
movwf PORTC
goto LOOP

Which should work although all it does is make all the pins of PORTC high.

Conclusion - you have either not set the config fuses correctly (is it a genuine Pickit 2?) or you have a hardware mistake.
1. Do you have /MCLR pulled high?
2. Are you really using a crystal oscillator and is it's frequency below 4MHZ?
3. Have you connected all supply pins and decoupled them with a suitable capacitor?

Brian.
 

what is the config fuses? My pickit2 is just a clone of the original microchip but still has the appropriate pin. I directly connected the Vpp pin of the Pickit2 to the pin of /MCLR of the MCU. Was the correct? Yes I am really using 4 MHz crystal oscillator and 2 pcs of 15pF parallel to it to the ground.Yes, I connected all supply pins but I don't have anymore capacitor connected to it. For the supply, I am using 9V battery of the eveready and connect if with L7805CV and output a voltage of 5V. Do you have a schematic for just output port of the MCU? I was starting to doubt that maybe my MCU is too old maybe not more than 4 months ago that I've used it awhile. I was just testing if my pic16f877a still working if not maybe I should by a new MCU.
 

The MCU should be fine, I have 16F877A devices here that have been running continuously for the past five or six years.

The reason I asked about the Pickit2 is that some clones do not program the configuration fuses properly. If yours is an accurate copy of the original and you are using Microchips own software it should be OK. The configuration fuses can only be set when programming the IC, they decide things like which kind of oscillator is being used and whether the watchdog should be running. Obviously, there would be no point in your program deciding what kind of oscillator to use if the MCU couldn't start anyway! It is correct to connect /MCLR to VPP and if you connect it wrongly the PicKit should warn you anyway.

You should have capacitors across the input of your regulator (across the battery wires) but physically very close to the regulator and you shoudl also have capacitors across VSS and VDD of the MCU. I suggest 10uF and 100nF in parallel in both cases. you should also have a resistor (10K) wired between /MCLR and VDD to ensure the PIC is not in reset condition.

The output on PORTC should go high when the program runs so you should have a resistor and LED connected between one of the PORTC pins and ground with the LED cathode side toward ground.

Brian.
 

Hi,

Here is some proven flasher code I already have, it runs in simulation and on hardware ok.

Code:
		list p=16f877a
		include p16f877a.inc
		__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON & _LVP_OFF
	
		cblock 0X30
		d1
		d2
		d3
		COUNT
		endc



		org 	0x00
		GOTO	Main



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

		

LOOP
		CALL	DELAY1
		MOVLW   0xFF
		MOVWF	PORTB		; Set  port HIGH

		CALL	DELAY1

		MOVLW   0x00
		MOVWF	PORTB		; Set  port LOW
		GOTO	LOOP		

	
DELAY1					; 4 SECOND DELAY
		movlw	0x23
		movwf	d1
		movlw	0xB9
		movwf	d2
		movlw	0x09
		movwf	d3
Delay_0
		decfsz	d1, f
		goto	$+2
		decfsz	d2, f
		goto	$+2
		decfsz	d3, f
		goto	Delay_0
	
				;6 cycles
		goto	$+1
		goto	$+1
		goto	$+1
		return

		END
 

Attachments

  • flash).jpg
    flash).jpg
    121.1 KB · Views: 85

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top