anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Thu Nov 05, 2009 7:14 am |
|
|
Here is my CODE Not for finding distance, as beginning just display the ccp1 reg value.
Code: |
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=20000000)
#include <lcd.c>
BOOLEAN tj=false;
#int_ccp1
void calc()
{
static int32 val;
int32 cv;
clear_interrupt(INT_CCP1);
if(tj == false)
{
val = get_timer1();
tj = true;
}
else
{
cv = ccp_1;
printf(lcd_putc,"\f%ul",cv);
}
}
void main()
{
int a=0,b=0;
set_timer1(0);
setup_timer_1(T1_INTERNAL);
setup_ccp1(CCP_CAPTURE_FE);
clear_interrupt(INT_CCP1);
enable_interrupts(INT_CCP1);
enable_interrupts(GLOBAL);
lcd_init();
delay_ms(100);
printf(lcd_putc,"Range Meter");
delay_ms(500);
while(1)
{
set_timer1(0);
tj = false;
interrupt_active(INT_CCP1);
for(a=255;a=0;a--){
output_high(pin_c1);
delay_us(12);
output_low(pin_c1);
delay_us(12); }
delay_ms(500);
}
} |
The Value in ccp reg. varies randomly.
Now i am going to change my hardware for using the circuit developer's HEX. |
|