We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
PLEASE FIND D CODE BELOW AND SUGGEST CHANGES I NEED TO MAKE TO GET "OFF TIME OF SQUARE PULSE".. . i am using EX0 and TR0 interrupt to find low pulse time.
THANKS IN ADVANCE.
/*program to find the toff*/
#include <reg51.h> #include <stdio.h>
sbit led=P1^0;
unsigned int count = 0,flag=0;
void EX0_ISR (void) interrupt 0 { TR0=1; if(INT0) TR0=0; EX0=0; }
void ET0_ISR(void) interrupt 1 { count++; TF0=0; }
void main (void) { SCON = 0x50; TMOD = 0x20; //timer 1 mode 2 auto reload TH1=-3;//9600 //TH1 = 0xFA; //Baud=9600 or -6d TR1 = 1; TI = 1; //PCON = 0x80; //setting SMOD TMOD = (TMOD & 0xF0) | 0x09; //value of TMOD =0x29 timer 0 for 16 bit mode 1
EA=EX0=ET0=1;
count=0; TH0=TL0=0;
while(1) { IT0=1; result=((unsigned long)((TH0<< 8) |TL0 | ((unsigned long)count << 16))); printf ("\noff pulse... %ld nSec\n", result);
} }
/////////////////////////////////////////////////////////////////////////////
SORRY, 'D' IS NOT A SUPPORTED LAMGUAGE - PLEASE POST IN 'C'.
And do it properly: www.danlhenry.com/.../keil_code.png