Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

PIC 18F452 circuit reset problem in PROTEUS simulation

Status
Not open for further replies.

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
Hi,

i'm using PIC18F452 for my development. the circuit is resetting during the simulation process.the circuit image is attached here..

thanks in advance.
 

Attachments


BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
Code:
#include<pic18.h>
#include"pic_lcd8.h"

void main()
{
	TRISD=0x00;
	TRISC=0X00;
	Lcd8_Init();
	Lcd8_Display(0x80,"PIC18F452 TESTIN",16);
	Delay(500);
	
	while(1)
	{
		Lcd8_Display(0x80,"................",16);
		Delay(500);			
		while(1);
	}		
}
 

hemnath

Advanced Member level 2
Joined
Jun 24, 2012
Messages
676
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Activity points
6,410
Connection to MCLR must goes high. It should be +5V.
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
Hi,

As Jayanth says you need to post your code, thats where the cause will be.

I would not use those value components in an actual circuit, instead try -
R1 = 10K
C1,C2 = 22PF
C3 = 100NF
You need a resistor in series with the LED, typically 330R

In Isis you do not need to connect pins 1,2 and 3 of the lcd up.
In an actual circuit the 10k resistor is a trimmer with its slider going to Vee and the other outer connections to +5v and 0v
If you look around there are code examples where the lcd uses just 4 bits for the data instead of 8bits
 

Ogu Reginald

Full Member level 6
Joined
Oct 7, 2011
Messages
369
Helped
46
Reputation
92
Reaction score
45
Trophy points
1,308
Location
Nigeria
Activity points
3,391
Let me try simulating the circuit, I will get back to you.

- - - Updated - - -

Let me try simulating the circuit, I will get back to you.
 

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
@hemnath and @wp100 - thank u sir....i'v made the changes in the circuit.Bt, there exist the same problem.
 

Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0
What clock frequency did you compile the code for and which Compiler are you using? Are you getting anything on LCD? As wp100 said it is better to use 4 bit LCD.
Why there is 2 while(1) loops. When your code is executed it will never come out of the second while(1) loop.

Zip and post your project files and proteus .dsn file. Also include pic_lcd8.h
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
Hi,

Have you right clicked on the 452 and opened up the 'properties' box and specified both your program code location and oscillator frequency ?

Again Isis takes no notice of your crystal in the diagram, it can be left out all together.
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
I don't see the configuration bits in the code. Ensure that you've set them properly. Make sure you've disabled the watch-dog timer.

Change value of C1 and C2 to 22pF. You can simulate the circuit without C1, C2 and X1 (for simulation purposes only).

As already mentioned, you need to use a current-limiting resistor for the LED (D1).

Hope this helps.
Tahmid.
 

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
thanks all....
the led having no role in the circuit ....as i mensioned the problem is regarding resetting the circuit. the last ""while(1);""statement is used to terminate the program.
but, it is not terminating there and again executing the code.

the latest edited code is given and the circuit too....

Code:
#include<pic18.h>
#include"pic_lcd8.h"

#pragma config WDT = OFF

void main()
{
	TRISD=0x00;
	TRISC=0X00;
	Lcd8_Init();
	Lcd8_Display(0x80,"PIC18F452 TESTIN",16);
	Delay(500);
	
	while(1)
	{
		Lcd8_Display(0x80,"................",16);
		Delay(500);			
		while(1);
	}		
}
 

Attachments

Last edited:

Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0
How does the 2 while(1) loop terminate the program. Are you saying that making your mcu run a infinite while loop makes it terminate the execution of your program?
Zip and post your project files and proteus.dsn file so that it can be checked. What frequency did you compile the code for?
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
thanks all....
the led having no role in the circuit ....as i mensioned the problem is regarding resetting the circuit. the last ""while(1);""statement is used to terminate the program.
but, it is not terminating there and again executing the code.
Hi ,

Cannot help with the C code, but here is a working example of the 452 and lcd.

Just unpack it to C drive and click on the 452lcd file to run it.
 

Attachments


BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
@jayanath-
the first while loop will make the loop infinite ....the second while loop will stop the program...the program is successfully running in other controllers like pic16f877a..
proteus file s attaching here...
 

Attachments


Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0
Which compiler are you using? c18?

- - - Updated - - -

Post your pic_lcd8.h file. I have to see weather it used 3 control lines or 2 control lines. One problem might be that your code used PORTx instead of LATx.
 

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
c18 compiler is using...
 

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
sry sir..herev s d coding.

Code:
#define First_Line    0x80
#define Second_Line   0xc0
#define Curser_On     0x0f
#define Curser_Off    0x0c
#define Clear_Display 0x01
#define Data_Port PORTD

static bit   Lcd_rs  @((unsigned) &PORTC*8+4); 
static bit   Lcd_en  @((unsigned) &PORTC*8+5);

void Lcd8_Init();
void Lcd8_Command(unsigned char);
void Lcd8_Write(unsigned char,unsigned char);
void Lcd8_Display(unsigned char,const unsigned char*,unsigned int);
void Lcd8_Decimal2(unsigned char,unsigned char);
void Lcd8_Decimal3(unsigned char,unsigned char);
void Lcd8_Decimal4(unsigned char,unsigned int);
void Delay(unsigned int);

void Lcd8_Init()
{
	Lcd8_Command(0x38);		//to select function set
	Lcd8_Command(0x06);		//entry mode set
	Lcd8_Command(0x0c);		//display on
	Lcd8_Command(0x01);		//clear display
}

void Lcd8_Command(unsigned char com)
{
	Data_Port=com;
	Lcd_en=1;
	Lcd_rs=0;
	Delay(125);
	Lcd_en=0;
	Delay(125);
}

void Lcd8_Write(unsigned char com,unsigned char lr)
{
	Lcd8_Command(com);

	Data_Port=lr;			// Data 
	Lcd_en=1;
	Lcd_rs=1;
	Delay(125);
	Lcd_en=0;
	Delay(125);
}

void Lcd8_Display(unsigned char com,const unsigned char *word,unsigned int n)
{
	unsigned char Lcd_i;

	for(Lcd_i=0;Lcd_i<n;Lcd_i++)
	{ 
		Lcd8_Write(com+Lcd_i,word[Lcd_i]);
  	}
}
 
void Lcd8_Decimal2(unsigned char com,unsigned char val)
{
	unsigned int Lcd_hr,Lcd_t,Lcd_o;

	Lcd_hr=val%100;
	Lcd_t=Lcd_hr/10;
	Lcd_o=Lcd_hr%10;
	
	Lcd8_Write(com,Lcd_t+0x30);
	Lcd8_Write(com+1,Lcd_o+0x30);
}


void Lcd8_Decimal3(unsigned char com,unsigned char val)
{
	unsigned int Lcd_h,Lcd_hr,Lcd_t,Lcd_o;

	Lcd_h=val/100;
	Lcd_hr=val%100;
	Lcd_t=Lcd_hr/10;
	Lcd_o=Lcd_hr%10;
	
	Lcd8_Write(com,Lcd_h+0x30);
	Lcd8_Write(com+1,Lcd_t+0x30);
	Lcd8_Write(com+2,Lcd_o+0x30);
}

void Lcd8_Decimal4(unsigned char com,unsigned int val) 
{
	unsigned int Lcd_th,Lcd_thr,Lcd_h,Lcd_hr,Lcd_t,Lcd_o;

	val = val%10000;
	Lcd_th=val/1000;
	Lcd_thr=val%1000;
	Lcd_h=Lcd_thr/100;
	Lcd_hr=Lcd_thr%100;
	Lcd_t=Lcd_hr/10;
	Lcd_o=Lcd_hr%10;

	Lcd8_Write(com,Lcd_th+0x30);
	Lcd8_Write(com+1,Lcd_h+0x30);
	Lcd8_Write(com+2,Lcd_t+0x30);
	Lcd8_Write(com+3,Lcd_o+0x30);
}

void Delay(unsigned int del)
{
	while(del--);
}
 

BISH

Junior Member level 2
Joined
Nov 3, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,418
thanks all....problem solved...

the problem is that : i have to select hitech universal tool suit with hitech c pic18 compiler
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top