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] pic 18f452 basic circuit problem

Status
Not open for further replies.

cheetha

Full Member level 2
Joined
Sep 17, 2011
Messages
146
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
2,310
I am using PIC 18f452 micro controller initially i just want to blink an led but problem is the circuit is working fine in proteus simulation but not in hardware. I am using 4MHz oscillator and is unable to get any waveform from the crystal oscillator on oscilloscope and output from RB0 pin remains low .... I also used resistor capacitor combination at OSC1 pin then i measured the frequency of 0.03MHz at OSC1 pin and the output remains high .....I also tried to apply the frequency of 1MHz from function generator at OSC1 still the output remains low.
I had also problem with genius G540 programmer that it was neither reading the device ID nor was programming my ic then i used PIC kit2 it was working fine programming as well as reading the program from the memory.
What could be the problem with my hardware and with Genius G540 programer


Thanks in Advance
 

hi,
use 4 MHZ cristal and two 22 pf capacitors (like in datasheet) , ... and do not forget to tie up the MCLR pin to VDD (V+) with a 10 k ohm rezistor

Ps: it is possible that when you conect the scope you "kill" the oscilator
 

i used 15pf capacitors with 4 MHz crystal and i used 4.7K ohm at MCLR
is there any way to determine whether the frequency is generated or not

thanks
 

Hi,

Those values should work, you really need to post your code / config bits and make sure thats right, simulations are not 100% identical to hardware.

Are you using a breadboard ?
 

the code is simple

#include p18f452.inc
ORG 0000H
clrf TRISB
movlw 0ffh
MOVWF PORTB
again:
SETf PORTB
call DELAY
CLRf PORTB
CALL DELAY
bra again

DELAY:
MOVLW 0FH
MOVWF 02H
AGAIN1:
NOP
NOP
DECF 02,f
BNZ AGAIN1
RETURN
end


the configuration bits are shown in image

yes i am using the bread board

is there any way to determine whether the frequency is generated or not

thanks

https://obrazki.elektroda.pl/4073823500_1357405595.html
 

Hi,

Just checked you code and its not 100% correct.

First the delay time is 83us based on a 4mhz crystal to you will never see the led actually flash, not sure how it worked in your simulation.

Second and importantly your configuration bits are wrong, partic the LVP programming is ON, it must be off for the Pickit2/3.

Third, a known problem with breadboards, the crystal and cap wires are very thin and can give poor contact, so loosing the signal.
Make up a bit of strip board or similar to solder the caps and crystal together, then fit three thicker wires to plug into the breadboard, keeping them as short as possible.

Do you want to correct your code or do you want me to provide a 1 second flashing led example ?
 

i check the output on oscilloscope and there was no any frequency or waveform just a straight DC line....yes i will be very thankful if you provide the code..
further i also checked the oscillator pins cap pins as well as controller pins and they appear to be connected...
i will try with LVP off
was it the same problem that caused genius G540 not to work?


thanks alot
 

Hi,

When you program with a PK2, by default it should program and verify the code; are you doing that ?

The PK2 should not have LVP ON, I have correctly set up all the configuration values in the code, so ensure the Config menu has the little box 'config bits set in code' ticked on.

Do not know anything about the Genius programmer, LVP could be the cause of your problems.

Code:
	LIST P=18F452,r=hex,n=80,x=off,st=off

	#include <P18F452.INC>	 

;	Configuration bits 
;	==================
  
    CONFIG OSC=XT, PWRT=ON, BOR=OFF, WDT=OFF, LVP=OFF, DEBUG=OFF


	cblock 0x000   ; start of ram memory
	d1,d2,d3	   ; delay work files
	endc

	ORG 0000H
	goto start

start
	clrf TRISB
	movlw 0ffh
	MOVWF PORTB
again:
	SETF PORTB
	call DELAY
	CLRf PORTB
	CALL DELAY
	bra again
	



; Subroutine
; Delay = 1 seconds
; Clock frequency = 4 MHz

DELAY
	movlw	0x08
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
DLY0
	decfsz	d1, f
	goto	DLY1
	decfsz	d2, f
DLY1
	goto	DLY2
	decfsz	d3, f
DLY2
	goto	DLY0

	return

	end
 

thanks alot the circuit worked perfectly
thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top