My first program in Proteus for PIC18F452

Status
Not open for further replies.
Four things need reevaluation:
1) Configurations bits, were they properly programmed, in simulation the program does execute, but with improper burned config bits the controller will not execute the program
2) In the actual circuit (hardware) did you use a 10K resistor between MCLR and +5V.
3)Is the oscillator working properly, have you used 22p capacitors between resonator and ground.
4) have you checked LED polarity.
on a side note check the mcu controller pins particularly supply and output with a multimeter.
 

My hard ware circuit is now operative on breadboard. But it functions only when I touch the oscillator. How should I resolve this issue?
 

Hi,

You need to show the assemler code and circuit diagram you are using now.
 

My hard ware circuit is now operative on breadboard. But it functions only when I touch the oscillator. How should I resolve this issue?

Seems to me, there are grounding issues, check if the oscillator is properly connected.
Have you placed 22-33pf capacitors between ground and oscillator pins?
 

Yes the oscillator is properly connected. I am using 20MHz crystal with two 15pF capacitors.

---------- Post added at 05:44 ---------- Previous post was at 05:41 ----------

Here is the code I am using:

list P=PIC18F452
#include P18F452.inc
R1 EQU 0X07
R2 EQU 0X08
ORG 0
CLRF TRISB
MOVLW 0X55
MOVWF PORTB
L3 COMF PORTB,F
CALL DELAY
BRA L3
DELAY
MOVLW H'FF'
MOVWF R1
D1 MOVLW D'250'
MOVWF R2
D2 NOP
NOP
DECF R2,F
BNZ D2
DECF R1,F
BNZ D1
RETURN
END

---------- Post added at 05:49 ---------- Previous post was at 05:44 ----------

Circuit is same as already uploaded in this thread, infact what you sent me. The only change I made now is that I am using Port B instead of Port D for output.
 

Hi,

Two things - first you need a config line to tell it you are using a HS type of crystal CONFIG OSC = HS, PWRT=ON, WDT=OFF, LVP=OFF, DEBUG=OFF.
Insert it after your include line.

Second, at 20meg your Delay loop is just 64 milli seconds so you will never see the leds switch on and off - they will probably glow slightly.
Use this site to calculate a 500ms delay for you.
**broken link removed**

You can use MPlabs SIM to check your timings and code flow.
 

Attachments

  • ScreenShot001.jpg
    113.1 KB · Views: 99

This is the configuration bit setting for PIC18
Code:
#pragma config OSC = HS, OSCS = ON
#pragma config BORV = 45, PWRT = ON, BOR = ON
#pragma config WDT = ON
#pragma config DEBUG = ON, LVP = ON, STVR = ON
 

The led part you have used in proteus is wromg. Try to use LED RED, LED GREEN, or LED YELLOW.
 

This is the configuration bit setting for PIC18
Code:
#pragma config OSC = HS, OSCS = ON
#pragma config BORV = 45, PWRT = ON, BOR = ON
#pragma config WDT = ON
#pragma config DEBUG = ON, LVP = ON, STVR = ON


Hi,

Is that a statement of fact or a question ?

If its a statement of what you are using it looks unusual to me, Watchdog On, Low voltage programmer On ?
 

hi,

these are the configuration bits i'v usedin my coding n worked properly..
sry, if you are not looking forward for

- - - Updated - - -

hi,

these are the configuration bits i'v usedin my coding n worked properly..
sry, if you are not looking forward for the config.bits
 

Hi,

You do not say what programmer you are using, but most like the Pickit2 and Pickit3 types are High voltage types.
Unless you are using a Low voltage programmer you should set LVP=OFF.
With LVP=ON you loose the normal digital pin functions of RB5


The same with the Watchdog, unless you have programmed the Watchdog settings in your code it will be Resetting the progam all the time.
See the datasheet for details.
 

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…