I'm trying to develop a program using C and a CCS compiler that will calculate the duty cycle of an ADXL202E accelerometer on an 16F877 PIN_B7 using #int_RB. Here's the code of the interrupt service routine. #int_RB void accelerometer_isr(void) { reading = get_timer1(); //Read Timer_1 current_portb = input_b(); //Read value of PORT_B delta_portb = current_portb ^ last_portb; //Did PORT_B change? last_portb = current_portb; //Remember PORT_B value if (delta_portb = 0x80 || 0xc0) //If PIN_B7 has changed { if (bit_test(current_portb, 7)) //If PIN_B7 is high { period = reading - old_reading; //Calculate period old_reading = reading; } else duty = reading - old_reading; //Calculate duty } else; } When I run the program I consistently get values of around 5200 for the period, while values for duty vary between 3 values; 2380, 2675 and 4950. I've checked the output of PIN_B7 with an old analog scope and the value of 2380 seems to be the right one. Any ideas on what's happening here? Thanks, Harry -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist