code working in simulation but not working in hardware

Thread Starter

ect_09

Joined May 6, 2012
180
Hello,
I am using PIC18F452 with MPLAB and HI-TECH compiler.
i write this code that take input and show the corresponding output. simulation showing that its working OK,
but when burn the hex file not taking the input.
Code:
#include<htc.h>

__CONFIG(1,OSCSDIS & HSPLL);
__CONFIG(2,PWRTDIS & WDTDIS & BORDIS);
__CONFIG(3,CCP2RC1);
__CONFIG(4,LVPDIS & STVREN);
__CONFIG(5, UNPROTECT);
__CONFIG(6,WRTEN);
__CONFIG(7,TRU);



void main()
{
TRISB4=1;
TRISD=0;

while(1)
{
   
if(!RB4)
{
PORTD=0x45;
}
else
{
LATD=0xFF;
}
}
}
 

ErnieM

Joined Apr 24, 2011
8,377
That's a pretty good choice for a PIC to begin with. I keep seeing people trying to use near obsolete 16F devices, probably because 10 year old web sites still list them.

Anyway, the only thing I wish for you was to have chosen a PIC with an internal oscillator. That is a good default to have in your back pocket as it works without any external parts. That's handy when getting the thing to work the first time.

When you burned the hex file, what did you use? Did it report success?

What hardware do you use? Got a schematic? Got a picture of the build to show?

Any further information you can give will help with clues to fix this.
 

ErnieM

Joined Apr 24, 2011
8,377
Ouch... clone programmers can't be used for in circuit debugging. Oh well....

Do you have a schematic? That's my next step to inspect.
 
Top