CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CCP Help needed
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
anandpv2009



Joined: 26 Jul 2009
Posts: 31

View user's profile Send private message

PostPosted: Thu Nov 05, 2009 7:14 am     Reply with quote

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.
Jerson



Joined: 31 Jul 2009
Posts: 126
Location: Bombay, India

View user's profile Send private message Visit poster's website

PostPosted: Thu Nov 05, 2009 9:35 am     Reply with quote

http://www.micro-examples.com/public/microex-navig/doc/090-ultrasonic-ranger

shows a simpler example of how-to sonar
_________________
Regards
Jerson Fernandes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group