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

problem in proximity sensor signal detection...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

problem in proximity sensor signal detection...
PostPosted: Wed Nov 21, 2007 8:51 pm     Reply with quote

hai,

i count the proximity sensor data.. i connect the seven segment
(A point) and proximity output in same pin RB7. i write the external interrupt to read the proximity data that time i configure the port as input port.. and then configure the port as output port and display the count data in seven segment. but program is count three times only.... my program is show below...

i used RB0 for other interrupt...

Code:
#include<16f873a.h>
#include<math.h>
#use delay(clock=20000000)
#fuses NOWDT,HS, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT
#byte port_b=6
int CONST LED_MAP[10] = {0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xe6};
#define LOWTOHIGH TRUE
#define HIGHTOLOW FALSE
long int count=0;
long int d1,d2,d3,d4;
short int dbutton7;
int last1=0;
int current;

 
   
void display(long int a1)     // display function for segment LED
{
set_tris_b(0x01);   //set RB0- Input and other are output...
//delay_ms(20);
 d1=a1/1000;                  //separate four digits
 d2=(a1-1000*d1)/100;
 d3=(a1-1000*d1-100*d2)/10;
 d4=(a1-1000*d1-100*d2-10*d3);



output_high(pin_c4);
port_b= LED_MAP[d1];
delay_ms(1);
output_low(pin_c4);

output_high(pin_c5);
port_b= LED_MAP[d2];
delay_ms(1);
output_low(pin_c5);


output_high(pin_c6);
port_b= LED_MAP[d3];
delay_ms(1);
output_low(pin_c6);



output_high(pin_c7);
port_b= LED_MAP[d4];
delay_ms(1);
output_low(pin_c7);

last1=current;

set_tris_b(0x81); // set RB7 and RB0 are input and other are output..
   
}



#int_rb
void detect_rb_change() {
 
   static int last=0;

   set_tris_b(0x81);
   current=input_b();
   if ((!bit_test(last,7))&&(bit_test(current,7))) {dbutton7=1;}
   last=current;


}


void main() {

   dbutton7=0;
   enable_interrupts(INT_RB);
   enable_interrupts(GLOBAL);
   output_low(PIN_a0);
   while (TRUE) {

        display(count);
        if(dbutton7)
        {
        count=count+1;
        dbutton7=FALSE;
        }
        if ( count>=9999) count=0;
   }
}

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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