manoj
Inactive
Offline
Posts: 4
Thank You
-Given: 8
-Receive: 0
|
 |
« on: March 12, 2008, 12:05:36 12:05 » |
|
hi pls see my program to count the period between two pulses.I didn,t get anything and I think the interrupt is not working. pls helplong int x=0,y=0,tmpl=0,tmph=0,oldstate=0;
long int x=0,y=0,tmpl=0,tmph=0,oldstate=0; long int j; char count[10]; void main (){ Lcd_Init(&PORTB); TRISA=255; TRISB=0; INTCON.GIE=1; INTCON.PEIE=1; PIR1.TMR1IF=0; PIE1.TMR1IE=0;
if(Button(&PORTA,0,1,0)) oldstate=0; if (oldstate&& Button(&PORTA ,0,1,1)){ PIE1.TMR1IE=1; T1CON.TMR1ON=1;}
while(PIR1.TMR1IF==0){ T1CON.TMR1ON=0; INTCON.GIE=0; INTCON.PEIE=0; PIR1.TMR1IF=0; PIE1.TMR1IE=0;} tmpl=TMR1L; tmph=TMR1H; y=1000000*x; j=(tmpl+tmph+y); IntToStr(tmpl,count); Lcd_Cmd(LCD_CLEAR); Lcd_Cmd(LCD_CURSOR_OFF); Lcd_Out(1,2,"HEART RATE:"); Lcd_Out(2,3,count); } void interrupt(){ while(PIR1.TMR1IF){ x++; PIR1.TMR1IF=0;} }
|