Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

8051 led blink problem

Status
Not open for further replies.
Hi I am aashish, I am a pure beginner to 8051 microcontrollers and want to Blink a LED with it (as my first test).

But at the end the LED did not blin, LED glows continuously and dimmer.

I performed the following steps,
1. Generate Hex file from keil uVision
2. Flash the AT89S52 with this hex file using a 8051 programmer.
3. Connect a LED to AT89S52 on breadboard to test my work.

Please have a look at the word document :https://drive.google.com/file/d/0B5NYQC3oiHcHcjh2a3RBOW5famc/edit?usp=sharing to see the detailed steps that I have followed along with the connection of LED to AT89S52 on breadboard to test my work

So where I was wrong? my program is incorrect/incomplete?? Or Does the AT89S52 not have an on chip clock? Whether I have to connect an external crystal?? Or anything I am missing….??


Please help me I am in a great need of it. Please help.


Thanks in advance.
 
First off...you're schematic shows the port pin sourcing LED current. 8051 pins cannot source that kind of current. They can, however, sink it.

Connect the cathode end of the LED (i.e. the minus end - ) to pin P1.0. Then connect a resistor to the anode of the LED (i.e. the +) end. Connect the opposite end of the resistor to +5V.

Then, if you're coding in C, this function should do it -

Code:
void main(void)
{
        P1 = 0b00000001;
        while(1)
        {
                for(int i = 0; i < 50,000; i++);
                P1 = P1 ^ 0b00000001;
        }
}

If you're coding in assembly -

Code:
        org    0x0000            ;reset vector  
        ajmp    START

;space reserved for interrupt vectors

        org    0x0100
START:        mov    P1, #00h
MAIN:        xrl    P1,#0b00000001        ;toggle LED
                    mov    R1, #FFh        ;delay loop
                    mov    R0, #FFh
LOOP1:       djnz    R1, LOOP1
                    djnz    R2, LOOP1
                    ajmp    MAIN            ;loop to main
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top