Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

unable to take input

Status
Not open for further replies.

srikanthind

New Member
i wrote a small program using pic 12f675. pin 3 has been as a input. but when i was giving input through stimulus, there would be no change.
the program as like below

C:
#
#include<pic.h>
#include<htc.h>

#define __XTAL_FREQ 4000000
//#include <delay.h>


#define GREEN 0b00000110


void interrupt Isr(void)

{
  if (GPIF)

   { 
        if(GPIO3==0)

          GPIO=0B001111111;

   }
   GPIF=0;


} 
    

void main(void)
{

  ANSEL = 0b00000000;
	OPTION = 0b11010001;
	CMCON = 0b00000000;
    TRISIO= 0B00001000;

     GIE = 1;
	//T0IE = 1;
	T0IF = 0;
    GPIF=0;
    IOCB=GPIO3; 
      
  //GPIO=0B00000100;

  __delay_ms(5);

  __delay_us(50);

  __delay_ms(200);

GPIO |= (1<<5);
GPIO &= ~(1<<7);
  GPIO=GREEN;                   

      while(1)
       {}
             
}

can someone find where it's going wrong?

thank you
 
Last edited by a moderator:
You need to use code tag to post you code it's the little button that look like a # on the middle left top bar where you post.

You have CMCON wrong it should be

Code:
CMCON = 0x7; or CMCON = 0b00000111;

And rethink what was said when some one showed you this.
Code:
GPIO |= (1<<5);
GPIO &= ~(1<<7);
 
Last edited:
Confusion about Pin3.... Pin 3 is GP4.....

Binary GPIO3 = 00001000 not 00000100

GPIO0 = 00000001 pin 7
GPIO1 = 00000010 pin 6
GPIO2 = 00000100 pin 5
GPIO3 = 00001000 pin 4
GPIO4 = 00010000 pin 3
GPIO5 = 00100000 pin 2
 
the input been taking the value sometimes, it didn't work earlier and its same program. but, interrupt is not occuring...
 
Status
Not open for further replies.

Latest threads

Back
Top