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.

PIC16F877A project works on emulator but not on chip!

Status
Not open for further replies.

kerden

Junior Member level 3
Junior Member level 3
Joined
Dec 11, 2004
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
284
A magical problem!!!!

hi:

I have edited a project using MCU of PIC16F877A.

it can work well on emluator ICD 1,but when i download on the chip it couldn't

work?

why ???

thank you!
 

Re: A magical problem!!!!

Turn off Watch dog timer, and be sure that you are using right oscillator type.
 

Re: A magical problem!!!!

Hi is NOT MAGICAL is plain simple..
On pics there are several CONFIGURATION bits that need to be set at the PROGRAMMING DEVICE level .. I mean at the moment when you download your code .These are .the type of oscilator type ,the reset ,brown on .check with a scope if your oscilator works .
 

Re: A magical problem!!!!

this is not a magical problem because it always happens to me,did you make sure that your MCLR\ pin is connected to Vcc? are you sure that your programmer works well? there are many possibilities...
 

Re: A magical problem!!!!

mipedja said:
Turn off Watch dog timer, and be sure that you are using right oscillator type.

Yes .
i have done.

Added after 45 minutes:

eltonjohn said:
Hi is NOT MAGICAL is plain simple..
On pics there are several CONFIGURATION bits that need to be set at the PROGRAMMING DEVICE level .. I mean at the moment when you download your code .These are .the type of oscilator type ,the reset ,brown on .check with a scope if your oscilator works .

CONFIGURATION bits like that:
 

Re: A magical problem!!!!

cmos babe said:
this is not a magical problem because it always happens to me,did you make sure that your MCLR\ pin is connected to Vcc? are you sure that your programmer works well? there are many possibilities...

i have done.

because it isn't every function doen't work when download to chip besides some.

so it dosn't hardware problem.

Added after 46 minutes:

Code:
#include"pic.h"

#define uchar unsigned char
#define uint unsigned int
#define Some_nop(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP();

extern set_inte();

uchar time_chang_flag;
uchar time_over_flag;
uchar set_clock1_flag;


void Key_init(void)
{
	TRISB |= 0x1f;
	OPTION &= 0x3f;
	RBIE = 1;
}
void delay(void)
{
	uint i;
	for(i=6553;--i;)
	continue;
}
void restart()
{
	RD1 = 0;
	time_over_flag = 0;
	set_clock1_flag = 0;
	time_buff = 2;
}
//********************************************************
main()
{
	uchar i,j;
	uchar time_buff;	
	
	TRISD = 0;
	PORTD = 0;	
	GIE = 1;
	
	Key_init();
	
	set_clock1_flag = 0;
	time_over_flag = 0;
	time_chang_flag = 0;
	time_buff = 2;	
	while(1)
	{
		if(time_chang_flag==1)
		{
			RD2=1;
			time_chang_flag = 0;
			time_buff = 0;	
		}
		if(time_buff < 1)
		{
			if(set_clock1_flag==0)
			{
				RD1 = 1;
				RD3=0;
				set_clock1_flag = 1;
				INTE = 1;
				set_inte();
			}
		}
		if(time_over_flag==1)
		{
			time_over_flag = 0;
			RD3=1;
			set_clock1_flag = 0;
			restart();
		}
	}
}
void interrupt interrupt_job()
{
	if(RBIF)
	{
		RBIF = 0;
		delay();
		PORTB = PORTB;
		if(RB4==0)
		{
			if(time_chang_flag==0)
			{
				time_chang_flag = 1;	
			}		
		}
		RBIF = 0;
	}
	if(INTF)
	{
		INTE = 0;//disable int wait clear 8563 alarm
		INTF = 0;
		time_over_flag = 1;		
	}
}
 

Re: A magical problem!!!!

Hi

I took a quick look at your code:

void interrupt interrupt_job()
{
   if(RBIF)
   {
      RBIF = 0;this must go after reading PORTB
      delay();not a good idea to use such a long delay inside an interrupt your processor will not be able to do anything else during this
      PORTB = PORTB;check if this is not optimized away by the compiler better use a variable
RBIF = 0;this must go here      
if(RB4==0)
      {
         if(time_chang_flag==0)
         {
            time_chang_flag = 1;   
         }      
      }
      RBIF = 0;
   }
   if(INTF)
   {
      INTE = 0;//disable int wait clear 8563 alarm
      INTF = 0;
      time_over_flag = 1;      
   }
}

By the way you never answered if the code I have posted in your last post is working now ...

best regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top