This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

turning a LED on

Hi
I am trying to see if my chip (atmel 89c51) works. I am trying to turn on a LEd through a switch. I used 11.0592 Mhz clock in pin # 19 then grounded the uC and put 5v vcc. I found several c program to turn the LED on but none of them work. Please anyone can help me by providing me a right program and tell me the right pin connection. Remember I am trying to turn the LED on through a switch.

Parents
  • I used 11.0592 Mhz clock in pin # 19 then grounded the uC and put 5v vcc.

    You need to connect the crystal to both pin 18 and 19 in order for the chip to function properly.

    If you want something easier to tell if your chip is working, connect an LED between Vcc and one of the pins on port 1, if possible. Then write a small assembly language program to toggle the pin. Using a C program to test an initial setup can be difficult because you might not be able to isolate where the problem actually is occuring (code vs. hardware).

    Here is a very poor but simple way of testing it out if the LED is connected between Vcc and P1.0 (through a resistor, of course!). This code should cause the LED to turn on and off at a fair rate. If you want to single-step through this in an emulator, take out the DJNZ instructions.

          ORG 0000h
    LOOP: MOV A, P1
          XRL A, #01h
          MOV P1, A
          CLR A
          MOV R0, A
          MOV R1, A
          DJNZ R0, $
          DJNZ R1, $
          SJMP LOOP
          END
    

Reply
  • I used 11.0592 Mhz clock in pin # 19 then grounded the uC and put 5v vcc.

    You need to connect the crystal to both pin 18 and 19 in order for the chip to function properly.

    If you want something easier to tell if your chip is working, connect an LED between Vcc and one of the pins on port 1, if possible. Then write a small assembly language program to toggle the pin. Using a C program to test an initial setup can be difficult because you might not be able to isolate where the problem actually is occuring (code vs. hardware).

    Here is a very poor but simple way of testing it out if the LED is connected between Vcc and P1.0 (through a resistor, of course!). This code should cause the LED to turn on and off at a fair rate. If you want to single-step through this in an emulator, take out the DJNZ instructions.

          ORG 0000h
    LOOP: MOV A, P1
          XRL A, #01h
          MOV P1, A
          CLR A
          MOV R0, A
          MOV R1, A
          DJNZ R0, $
          DJNZ R1, $
          SJMP LOOP
          END
    

Children