5 Replies Latest reply on Nov 23, 2015 2:01 PM by Vignesh_Mohanraj

    Pin Change Interrupts

    Vignesh_Mohanraj

      Programmers and Developers ,

       

       

      So far I have been working with Arduino and I thought let me try implementing the arduino code with the technologically advanced micro-controller "Intel Edison".

      I have a working arduino code which uses pin change interrupt control registers.  When I tried to compile in Intel edison using arduino I had errors stating that the PCICR( Pin change control register) is not declared. Where as in Arduino, I don't get this error because Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs.

      I have been googling around to get the details but I couldn't get it.

       

      Can someone help me by telling what is the exact name for the below variables of arduino  in Intel edison ?

       

      PCICR ( Pin change interrupt control register )

      PCIEO  ( Pin change enable 0)

      PCMSK0 ( Pin change mask register )

      PCINT ( Pin change interrupt)

       

      or is there anyway I could solve this problem ?

       

      Eagerly awaiting for your response !!

       

      ~Vignesh Mohanraj

        • 1. Re: Pin Change Interrupts
          Vincenze

          These are not Arduino variables. These are the registers of 8-bit Atmel microprocessors. They may not work even on the Arduino Due.

           

          Try the Arduino function attachInterrupt.

          Arduino - AttachInterrupt

          • 2. Re: Pin Change Interrupts
            Vignesh_Mohanraj

            Dear Vincenze,

             

            Thank you for your reply. Yes, you are right these are 8-bit Atmel microprocessor registers.  But, these registers are working in Arduino boards and I was able to successfully compile it. But now I want to do this in Intel Edison.


            This is my interrupt code which I have used to toggle between the outputs.


              PCICR |= (1 << PCIE0);                                           //Set PCIE0 to enable PCMSK0 scan.

              PCMSK0 |= (1 << PCINT0);                                     //Set PCINT0 (digital input 8) to trigger an interrupt on state change.

              PCMSK0 |= (1 << PCINT1);                                     //Set PCINT1 (digital input 9)to trigger an interrupt on state change.

              PCMSK0 |= (1 << PCINT2);                                     //Set PCINT2 (digital input 10)to trigger an interrupt on state change.

              PCMSK0 |= (1 << PCINT3);                                     //Set PCINT3 (digital input 11)to trigger an interrupt on state change.

             

            My question is can I try the similar method in Intel Edison (Atom Soc Microcontroller) ..provided if I know the exact register names in this microcontroller?  I am using this type of code in order to reduce the loop time in my project.  

             

            Can you suggest me some good idea to solve this problem?

             

            Thanks,

            Vignesh

            • 3. Re: Pin Change Interrupts
              Vincenze

              You can always try.

               

              Why wouldn't you try to use attachInterrupt like this.

               

              I'm not very familiar with Arduino on the Edison. But pin change interrupts are more complicated on 8-bit Atmel microprocessors because when an interrupt is triggered, you have to find in the interrupt handler function the pin that has triggered the interrupt. On the Edison, you can attach an individual interrupt to each pin, another pin won't trigger it.

               

              int pin =13;
              volatile int state =LOW;

               

              void setup(){
              pinMode(pin,INPUT);
              attachInterrupt(pin, blink,FALLING);
              }

               

              void blink(){
                  state =!state;
              }

               

              • 4. Re: Pin Change Interrupts
                Vignesh_Mohanraj

                Vincenze,

                 

                I tried to get the details but I was not successful in that. Now I am going to use the attachInterrupt function to test the project.

                 

                Thanks for your help and if I have any further problems I'll ask you.

                 

                 

                Thank you so much.

                • 5. Re: Pin Change Interrupts
                  Vignesh_Mohanraj

                  Vincenze,

                   

                  I tried attachInterrupt() function as you have previously asked me to try it. The good new is I am able to receive the data from the transmitter to the receiver and I am able to toggle the values too but, the values are fluctuating and it is not constant. I didn't have this problem when I used the register variables in Arduino. What could be the reason for the fluctuation of values? How can I make it stable?

                   

                  Sincerely,

                   

                  Vignesh