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] help to make delay using microcontroller atmel 89c2051

Status
Not open for further replies.

hamidooon

Junior Member level 1
Joined
Dec 10, 2015
Messages
16
Helped
2
Reputation
4
Reaction score
2
Trophy points
3
Activity points
169
Hi,
Can we make delay of 10 hr using 89c2051 microcontroller?
Please reply how to make delay program using c program.
 

Hi,

If you need a good answer, then you should provide good informations first.

What's the input? What's the output?
Digital, analog, via adc?
Give a detailed description, of how you want it to operate.

Klaus
 

Here's an example C program for a 10 hour delay using an 8051 mircocontroller.

Code:
#include <8051.h>

unsigned long count = 0;

// If CPU clock frequency is 12 Mhz, 
// Timer0 is incremented 12 million / 12 = 1 million times per second.
// Timer0 counts 65536 clock cycles and then interrupts as it rolls over to 0
// "count" is incremented 1 million / 65536 = 15.258789 times per second 
// 10 hours = 10 hours x 60 minutes x 60 seconds = 36000 seconds
// 36000 seconds x 15.258789 counts per second = 549316.4065 = 10 hours 


void timer0_isr(void) __interrupt 1  __using 1 
{     
    count++;
} 


int main()
{
    TMOD = 0x01;  // configure timer0 to 16 bit timer
    TH0 = 0x00;   // set timer0 to count to 65536
    TL0 = 0x00;         
    EA = 1;       // enable global interrupt
    ET0 = 1;      // enable timer0 interrupt
    TR0 = 1;      // start timer0 running   
   
    while(1)
      {
      if(count == 549316) // 10 hours has passed
        { }  // do whatever you want when 10 hours is up here  
      }    
}
 

I am working on device (relay) on off timer project. In that we give device on time and off time manually through switch .time will be displayed on 16x2 lcd display. When ckt turns on and we give on off times then device is on for that much of time and off for given time . After on time finished device again on for given time repeatedly.
I use ports 1.1 ,1.2, 1.3 as pushbutton input ports and LCDin 4 bit mode. Output device at port 3.0 of 8051.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top