To read values from port of microcontroller?

Status
Not open for further replies.

Pari Boopathy

Newbie level 6
Joined
Mar 13, 2014
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
94
I am connecting my IR receiver(Output to VCC and Ground to 7th pin of Port-C) to TM4C123GH6PM Microcontroller.
Whenever i press the button in TV remote,,the IR Receiver which receives the data using Pulse Length Technique..In coding i read the values using this command and store it in array..using CCS Compiler.
c=GPIOPinRead(GPIO_PORTC_BASE,GPIO_INT_PIN_7);

Is this command is enough to read the values from IR receiver?Whether it stores 12-bit(Command-7 bit and Address-5 bit) in that array by reading one time? Reply as soon as possible..
 

IR receiver will have 3 pins usually. VCC, GND, OUT. VCC should be connected to +5V, GND to GND and OUT to MCU input pin.
 

I don't know about much controller you are using and its API which you used but i assumed you doing coding in c language so its better you use pin in interrupt and stored your ones and zeros separately as shown example code below
Code:
    if((zero==1)||(one==1)) // if one or zero received, save it in rec array
     {
         if(zero==1)
         {
             rec[i]=0;
             i++;
             zero=0;
          }
 
          if(one==1)
          {
              rec[i]=1;
              i++;
              one=0;
           }
 
/*****************************************************/
 
          if(i==5) // if i=5, all code received
          {
              x=0;    z=4; i=0;
              for(n=1;n<=5;n++)
              {
                   if(z>25)
                   goto again;
 
                  for(j=x;j<=z;j++) // start checking codes if .......
                  {
                       if(code_x[j]==rec[j-x])
                       {
                            similar++; // if all numbers are equal, similar=5
                            if(similar==5)
                            {
                                 portb=n;
                                 for(m=0;m<=4;m++)
                                 {
                                      rec[m]=0;
                                 }
                                 similar=0; // when the correct code received
                                 goto again;
                             }
                        }
                    }
 
              x+=5;
              z+=5;
              similar=0;
         }
     }
 
}
   again:
   ccp1f=0;   //clear int overflow flag
   set_timer1(0);
   fall=0;
}

u can use this as reference
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…