Re: Get pulse width in mikroc
check mail and here is code in mikroc u may easily convert it to mikrocpro
unsigned char i=0,op[12]={48,48,48,48,48,48,48,48,48,48,48,48},lcd[12];
unsigned long timeperiod=0;
void interrupt(void)
{
i++;
if(intcon.int0if)
{
intcon.int0if=0;
///start timer
if(i==1)
{
TMR0L=0;
TMR0H=0;
T0CON.TMR0ON=1; ///START TIMER
INTCON2.INTEDG0=0;///INTERRUPT ON FALLING EDGE
}
if(i==2)
{
T0CON.TMR0ON=0; ///STop TIMER
INTCON2.INTEDG0=0;
INTCON2.INTEDG0=1;///INTERRUPT ON risING EDGE
timeperiod=TMR0H*65536+TMR0L;
timeperiod=timeperiod*256;
longtostr(timeperiod,op);
i=0;
}
}
if(intcon.TMR0IF)
{
intcon.TMR0IF=0;
}
}
void main(void)
{
trisb.f0=1;
trisd=0;
lcd_config(&portd,0,2,1,7,6,5,4);
lcd_cmd(lcd_cursor_off);
T0CON=7;///PREESCALAR 256
INTCON=0xb0; ///enable timer0 and external interrupt
TMR0L=0;
TMR0H=0;
while(1)
{
lcd_out(1,1,"timeperiod:");
// lcd_chr(2,1,i+48);
lcd_out(2,1,op);
lcd_out_cp("usec");
delay_ms(500);
lcd_cmd(lcd_clear);
INTCON2.INTEDG0=1;
}
}
- - - Updated - - -
elsol why not Knowledge is *** given
i have attached code bt if not understanding kindly send me email address