> What I'm trying to do is decode my remote control. For right now, I just > have Timer1 setup with DIV_BY_1 and my CCP is set to capture on falling > edge (inverted output from IR receiver). I was just goofing around with a Sony transmitter & CCS and came up with this. #include <16F876A.h> #fuses HS,NOWDT,NOPROTECT,NOLVP #use delay(clock=20000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) #define pulsin_pin PIN_B1 long pulse[14]; // Up to 14 pulse results void pulsin(void) { int i; for(i=0; i<14; i++) // 0 to 13 { while (input(pulsin_pin)); // Hold while pulsin_pin = 1 set_timer1(0); // Zero timer1 on 1 to 0 transition while (!input(pulsin_pin)); // Hold while pulsin_pin = 0 pulse[i] = get_timer1(); // Read number of timer1 ticks for pulse time } } void main() { int i; float x; port_b_pullups(TRUE); // Hold input pin + IR detector output high disable_interrupts(GLOBAL); // Disable interrupts set_tris_b(0x01); // RB1 = pulse input setup_timer_1(T1_INTERNAL | T1_DIV_BY_1); // Internal clk + 1:1 prescale (200nS ticks) while(TRUE) { pulsin(); // Measure 14 pulses for(i=0; i<14; i++) // 0 to 13 { x = pulse[i] * 0.0000002; // x * 200nS = pulse width printf("Pulse %u = %01.6f \r\n",i, x); // Print pulsin results delay_ms(500); // Short delay between updates } // end for } // end while } // end main /* Result when pressing button #1 on Sony TV transmitter Pulse 0 = 0.002471 Start (2.4mS) header pulse Pulse 1 = 0.000667 Button code data bit #1 (600uS = 0) Pulse 2 = 0.000691 #2 Pulse 3 = 0.000644 #3 Pulse 4 = 0.000644 #4 Pulse 5 = 0.000667 #5 Pulse 6 = 0.000643 #6 Pulse 7 = 0.000691 #7 Pulse 8 = 0.001255 Sony TV device code bit #1 (1.2mS = 1) Pulse 9 = 0.000644 #2 Pulse 10 = 0.000644 #3 Pulse 11 = 0.000692 #4 Pulse 12 = 0.000644 #5 Pulse 13 = 0.002472 Next start pulse after 7 data + 5 device bits */ I have some CCS routines for a 15-key Sony type IR transmitter using the 16F628A w/internal osc. I can email you copies if you want to experiment with them. Regards, -Bruce tech@rentron.com http://www.rentron.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads