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.

[SOLVED] 8051 led glow for 1 second

Status
Not open for further replies.

khassan143

Newbie level 1
Joined
Jan 5, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
10
Hi guys, i want to ask about programming my at89s52 using Keil with clock frequency 12MHz.

have a switch connected to INT0 pin
when i press the switch an interrupt is to be generated and the LED should glow for one second
it will be very helpful if anybody could help me with the coding.
thanks in advance
 

You have to also use Timer interrupt. When INt0 triggers start the timer interrupt which interrupts say every 500 mS. Then use a counter to count the no. of timer interrupts. If counter value reaches 2 then 1 second will be elapsed. So, stop the timer and turn ON the LED.
 
  • Like
Reactions: mjasoj

    mjasoj

    Points: 2
    Helpful Answer Positive Rating
1. AT89S52 FREQUENCY IS 11.0592Mhz.

2. FIRST YOU ENABLE THE HARDWARE INTERRUPT [MOV IE,#1000010B]

3. THEN CLEAR THE PORT 3 BECAUSE LED IS CONNECT INTERRUPT PIN IS P3.2 AND P3.3 [MOV P3,#00H]

N:B-WHEN MICROCONTROLLER IS START ALL THE PIN IS FFH SO WE CLEAR THE PIN WHERE LED IS CONNECT

4.AND A LOOP IS CONTINUE
 

Your switch is connected in p3.2, which is used as a interrupt. So. that 1st you active the h/w-0 interrupt and when you pressed the switch then on the led and start the timer which should be used in mode-1 by which you can get long time and count the time when the time is complete for 1-sec then off your led.
 

By the way, the general wisdom is that a hardware switch needs to be de-bounced. If you connect the switch to an interrupt, then expect the interrupt to be called multiple times within a few milliseconds so you need to handle this situation.
A search of the internet will show you many of the hardware and software ways to de-bounce a switch.
While this might not be an issue with the switch simply turning on a LED, if the requirements change slightly - to, say, having the switch toggle the LED - then you will get very erratic behavior until the switch is de-bounced.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top