prevravanth
New Member
Hi,
How to stop interrupt inthe the timer0 interrupt 1
my logic is
connect port 1.0
start delay for 2.5 sec
start Beep gen at 2.5 sec
stop port 1.0 at 3 sec
check my code is correct and give me some corrected code for this logic
The problem is i cannot stop the timer(i.e port 1.0 not disconnect at 3 sec)
Please help me
___________code_______________
#include<stdio.h>
#include<reg51.h>
#include<stdlib.h>
#include<absacc.h>
#include<intrins.h>
#include "ports.h"
void count(void);
void timdelay(unsigned int);
void main()
{
int i,t;
P0_1=1;
timdelay(500);
for(t=0;t<18;t++)
{
timdelay(1000); time delay for 3 minutes
}
while(1)
{
count();
}
}
void count()
{
TMOD=0x01;
TL0=0xFF; // TL0 Reload value
TH0=0xFE; // TH0 Reload value 1 Khz
ET0=1;
TR0=1; // Start Timer0
EA=1;
while(TF0==0); // Timer0 Over Flow flag=0
TR0=0; // Stop Timer1
TF0=0; // Reset Timer1 Over Flow Flag
}
void timer0() interrupt 1 /* interrupt address is 0x000b */
{
TF0 = 0; // reset interrupt flag
// P0_0 = ~P0_0; /* P1.0 toggle when interrupt. */
}
void timdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
How to stop interrupt inthe the timer0 interrupt 1
my logic is
connect port 1.0
start delay for 2.5 sec
start Beep gen at 2.5 sec
stop port 1.0 at 3 sec
check my code is correct and give me some corrected code for this logic
The problem is i cannot stop the timer(i.e port 1.0 not disconnect at 3 sec)
Please help me
___________code_______________
#include<stdio.h>
#include<reg51.h>
#include<stdlib.h>
#include<absacc.h>
#include<intrins.h>
#include "ports.h"
void count(void);
void timdelay(unsigned int);
void main()
{
int i,t;
P0_1=1;
timdelay(500);
for(t=0;t<18;t++)
{
timdelay(1000); time delay for 3 minutes
}
while(1)
{
count();
}
}
void count()
{
TMOD=0x01;
TL0=0xFF; // TL0 Reload value
TH0=0xFE; // TH0 Reload value 1 Khz
ET0=1;
TR0=1; // Start Timer0
EA=1;
while(TF0==0); // Timer0 Over Flow flag=0
TR0=0; // Stop Timer1
TF0=0; // Reset Timer1 Over Flow Flag
}
void timer0() interrupt 1 /* interrupt address is 0x000b */
{
TF0 = 0; // reset interrupt flag
// P0_0 = ~P0_0; /* P1.0 toggle when interrupt. */
}
void timdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}