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.

Need help on AT89C2051 code problem

Status
Not open for further replies.

gatzrulz

Newbie level 5
Joined
Oct 20, 2009
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,349
Hi all,

im facing the same problem... When i change the controller to 89s52 and load the hex in controller it works fine.. But when i select 89c2051 and burn the hex into the controller its not working. In debugging also only port bits are enabling. Somewhere problem with header or selection and sure that there is no problem with the hardware because it works fine with 89s52. Can anyone help me out pls.

I have attached the circuit.
led.JPG
device1.JPG
device.JPG
89c2051.JPG
 

Re: AT89C2051 code problem

I HAVE ATTACHED THE CODE HERE


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<reg51.h>
//#include<reg2051.h>
 
sbit LED = P1^0;
 
void delay(ms);
 
void main(void)
{
P1 = 0x00;
while(1)
{
LED = 1;
delay(20);
LED = 0;
delay(20);
 
}
}
 
void delay(time)
{
int a,b;
for(a=0;a<time;a++)
for(b=0;b<200;b++);
}

 
Last edited by a moderator:

The Port1 on 89s52 can source (a few mA)/sink current so can turn on the LED. It has internal pull ups on all Port1 pins.

89C2051 has only open collector ports with interal pull ups on SOME pins. Pins without pull up cannot sink surrent and cannot turn on LED. Port 1.0 has not internul pull up, you should add it if you want to use it.

Solutions:
a) add the LED and it's resistor, between port pin and +5V
b) remove 2,2K resistor from the LED and put it between port pin and +5V (as a pull up)
 
Last edited:

Hi,

Thanks. but the problem is with the software itself and not with the hardware. when im debugging with 89s52 controller the (P1 & Pins) both are toggling. but in 89c2051 only (P1) is toggling. i couldnt understand where exactly it went wrong.
 

when im debugging with 89s52 controller the (P1 & Pins) both are toggling. but in 89c2051 only (P1) is toggling.
There's no code that toggles pins except for P1.0. What do you mean? Which problem do you observe?
 

There's no code that toggles pins except for P1.0. What do you mean? Which problem do you observe?

Hi,
Its simple..i have selected 89s52 for the same code and compiled it and debugging was also working fine. In hardware also it works perfect. But when i select 89c2051 compiling was not an issue but when i debug it reacts differently. U can see my very first posts attachment where debuging screenshot was posted.

It doesnt work in hardware also. So i mean to say nothing wrong in hardware as the ckt common for both the controller. The front end code was also same. But i doubt the header or the supporting file and have a ittle doubt on the ide. Im using keil version 4..

Can you siggest some good ide in which i can try and confirm. I couldnt get any free stuff ide on net.

Thank you..
 

Change 2.2k resistor to 220 Ohms resistor and try. Try the attached .hex file compiled for 11.0592 MHz. I have included both Keil uVision project and mikroC PRO 8051 project.

Current for LED should be 10 mA.

According to your circuit

I LED = (V - V LED) / R

= (5 - 2.1) / 2200

= 0.0013181818181818 A

= 1.3 mA
 

Attachments

  • Keil uVision Projects.rar
    37.2 KB · Views: 111
  • mikroC PRO 8051 Projects.rar
    21 KB · Views: 57

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top