# uC programmed but does not works

Status
Not open for further replies.

#### Shaheers

##### Member level 2
I am trying to implement a simple blinking circuit on bread board to checking purpose

I try for both atmel 89s52 and PIC18F452 for testing
I program 89s52 on Mickro C and Keil,
and PIC18F452 on Micro C and CSS C as well

I use old computer power supply to power them,
I am using Genius G540 to program them

both of circuits are works on proteus but not in real world,

is there any problem with crystal clock?
is there any problem in programming device, that device is using some sort of encruption while programming.
Is there any problem with power supply?
Is both of uC are faulty, even it programs and verify. . .. ?

the simple program in keil and sch are given

Code:
#include <REGX51.H>
#include <stdio.H>
#include <math.H>

void main()
{
do{
int i;
for(i=0;i<10000;i++)
{
P2= 0x80;
}
for(i=0;i<10000;i++)
{
P2= 0x00;
}

}while (1);
}

#### Attachments

• 177.7 KB Views: 9

#### Tahmid

For the 89S52:

Connect pin 40 (VCC) (Not shown in Proteus) to +5V.
Connect pin 20 (GND) (Not shown in Protues) to ground.
Connect pin 9 (RST) to ground via a 10k resistor. Connect a 10uF capacitor from +5V to pin 9 (RST).

Take a look here: http://www.ikalogic.com/part-3-basic-inputoutput-operations/

Hope this helps.
Tahmid.

#### nandhu015

You need to reset circuit to operate.

Here is the basic circuit

Try this one

#### Shaheers

##### Member level 2
It does not works, LED is continuously ON

#### sequel

##### Member level 4
are you very sure of your programmer?

#### Tahmid

What is the frequency of the oscillator?

Your problem is that the delay you used is too small. While the LED does blink, the rate is too fast for our eyes to detect and it seems like the LED is on. Increase the delay time so that it's about 250ms or more.

- - - Updated - - -

You said that you tried using mikroC as well. Upload the mikroC code.

Also, upload the schematic and codes for the PIC.

#### bigdogguru

is there any problem with crystal clock?
What value of capacitors are you using for the crystal? Your schematic indicates 22nF, while a valid range is more in 20pF to 30pF range.

is there any problem in programming device, that device is using some sort of encruption while programming.
If the devices have been Code Protection enabled, you will need to manually erase the entire device before programming.

Is there any problem with power supply?
The power supply needs to be well regulated, proper use of bypass/decoupling capacitors is advisable.

Also some computer power supplies require a minimum load to function properly.

You might consider building a simply 7805 based power supply for your projects.

Is both of uC are faulty, even it programs and verify. . .. ?
Highly Doubtful.

BigDog

#### Shaheers

##### Member level 2
are you very sure of your programmer?
Yeh is just got a new one, i think this is not a reasion.

What is the frequency of the oscillator?
The oscillator freq is 20Mhz.

You said that you tried using mikroC as well. Upload the mikroC code.

Also, upload the schematic and codes for the PIC.

The code i use in MikroC is for 80s52

Code:
void main ()

{
unsigned char j=1;

for(;;)
{
P0=j;                                            // same as for pic, with TRISA=0; and PORTA;
P1=j;
P2=j;
P3=j;
Delay_ms(1500);
j=j<<1;
if(j==0)
{
j=1;
}
}
}
I think it is not a problem with code,

What value of capacitors are you using for the crystal? Your schematic indicates 22nF, while a valid range is more in 20pF to 30pF range.
I am sorry i got a problem, the problem is probably capacitor, let me fix this first. . .

Is there any alternator of that crystal, any possibility to use micro-controller without crystal, like RC or internal oscillator?

#### sequel

##### Member level 4
ground the body of the crystal, make sure you make good use of power supply filter capacitors, increase the ground plane of you circuit so as to lower the inductance, measure the supply voltage across the power pin (GND and VDD) to be sure that it is within the set values, recompile and assemble your program once again....cheers

- - - Updated - - -

when digital systems tend to show bizarre attitudes one of the best bet will be to run a lower crystal value first then if all went well you can then push it to the limits of the chip and not starting it all up from the other side because things make get so bad...without you being able to combat it within a short while.

Status
Not open for further replies.