Skip to main content
added 134 characters in body
Source Link

I'm using Timer 0 and Pin change interrupt for my work. And I need to decode IR signal with a normal way using the GP3(MCLR) pin.

My program is working fine with PIC16F877A which running with external OSC @ 16MHz. But when I using the same program for PIC12F675 itsit's not working for me.

I have disabled Pull-upsPull-ups and MCLRMCLR pin function for PIC12F675. And using the GP3 pin as the input for IR receiver.

My program is working fine with PIC16F877A which running with external OSC @ 16MHz. But when I using the same program for PIC12F675 its not working for me.

I have disabled Pull-ups and MCLR pin function for PIC12F675. And using the GP3 pin as the input for IR receiver.

I'm using Timer 0 and Pin change interrupt for my work. And I need to decode IR signal with a normal way using the GP3(MCLR) pin.

My program is working fine with PIC16F877A which running with external OSC @ 16MHz. But when I using the same program for PIC12F675 it's not working for me.

I have disabled Pull-ups and MCLR pin function for PIC12F675. And using the GP3 pin as the input for IR receiver.

added 15 characters in body
Source Link

Below is my program for PIC16F877A. Please, can someone help me to solve this problem for PIC12F675?

Below is my program. Please, can someone help me to solve this problem for PIC12F675?

Below is my program for PIC16F877A. Please, can someone help me to solve this problem for PIC12F675?

Source Link

PIC - Problem in NEC IR Decoding in PIC12F675

I'm using PIC12F675 with internal OSC running @ 4MHz. I'm using MikroC Pro compiler version 6.6.2.

To Decode NEC protocol, I'm not using Timer or Interrupt. I used delay command to make the code as simple as possible with time-out property and the code checks the IR signal with resolution of 50µs.

My program is working fine with PIC16F877A which running with external OSC @ 16MHz. But when I using the same program for PIC12F675 its not working for me.

I have disabled Pull-ups and MCLR pin function for PIC12F675. And using the GP3 pin as the input for IR receiver.

I'm using the example from here.

Below is my program. Please, can someone help me to solve this problem for PIC12F675?

Thank you

Chayan

/* Pin Configuration */
#define IR_PIN                RB0_bit       /**< IR Signal Reception Pin.*/
#define LED_PIN               RC5_bit

unsigned long ir_code;
unsigned int address;
unsigned short command, inv_command;


short nec_remote_read() {

unsigned long count = 0, i;
// Check 9ms pulse (remote control sends logic high)
while ((IR_PIN == 0) && (count < 190)) {
count++;
delay_us(50);
}
if ( (count > 189) || (count < 120))     // NEC protocol?
return 0;

count = 0;
// Check 4.5ms space (remote control sends logic low)
while (IR_PIN && (count < 95)) {
count++;
delay_us(50);
}
if ( (count > 94) || (count < 30))       // NEC protocol?
return 0;

// Read code message (32-bit)
for (i = 0; i < 32; i++) {
count = 0;
while ((IR_PIN == 0) && (count < 14)) {
  count++;
  delay_us(50);
}
if ( (count > 13) || (count < 2))     // NEC protocol?
  return 0;

count = 0;
while (IR_PIN && (count < 40)) {
  count++;
  delay_us(50);
}
if ( (count > 39) || (count < 4))     // NEC protocol?
  return 0;

if ( count > 20)                      // If space width > 1ms
  ir_code |= 1ul << (31 - i);         // Write 1 to bit (31 - i)
else                                  // If space width < 1ms
  ir_code &= ~(1ul << (31 - i));      // Write 0 to bit (31 - i)
}
return 1;
}

void main()
{
TRISB0_bit = 1;
TRISC5_bit = 0;

while(1) { //Loop executed infinite times

//while (IR_PIN);                //Wait until IR pin falls
if (nec_remote_read()) {
address = ir_code >> 16;
command = ir_code >> 8;
inv_command = ir_code;

switch(command){
  case 0x48:
  LED_PIN = 1;
  break;
  case 0x80:
  LED_PIN = 0;
  break;
   }
  }
 }
}