Using Pin Change Interrupt (PCINT) for wakeup


  • Contest Winner

    Hello,

    Can I use the Pinchange Interrupts (PCINT), which are available for every Pin, to wakeup the Arduino/MySensors module?

    I think I read in a Sketch which uses Sleep Mode that only the "real" 2 Interrupt pins can be used.
    Is this true? I also think that I saw a sketch somewhere where someone used the pinchange Interrupts to wake up (but it was not in conjunction with MySensors I think).

    Anyway has anybody tried to use PinChange Interrupts or can give some more Information on that topic?

    Tanks in advance
    Dirk_H


  • Mod

    @Dirk_H sure, you can use this interrupt on any pin.

    It is not a standard arduino future but I'm sure you can find someone else library for this.
    I personally did all needed programming just by reading atmel's datasheet, It is very simple to do it without any library,
    If you will need help this way just let me to know
    See register description page 56 http://www.atmel.com/images/atmel-7810-automotive-microcontrollers-atmega328p_datasheet.pdf#56


  • Hardware Contributor

    Hi.
    I am trying to use pin change interrupt. It does not compile with the master branch but it compiles well with the dev branch (maybe cleanings have been done in the dev branch).
    The compile error is about the PCINT2_vect. What can I change in the master branch to fix my problem. I think it is related to pinchangeint.h
    I have another question related to change interrupt.
    If i have an interrupt configured on d5 or d6 in the mask for example. And a sensor connected on pin of the same mask but with no interruption on its pin (a temp sensor for example).
    Does the sensor will trigger? Or it will use the mask rightly?

    I hope I am clear in my explanation.

    Here is the simple piece of code I added in my node:

    // Problem  here
    ISR(PCINT2_vect) {
      Serial.print("Interruption : ON");
    }
    In setup() I add this :
    PCMSK2 = PCMSK2 | B00010000;
    PCIFR = PCIFR | B00000100;
    PCICR = PCICR | B00000100;
    
    MySensors\MyGateway.cpp.o: In function `__vector_5':
    C:\Users\Pascal\Documents\Arduino\libraries\MySensors\utility/PinChangeInt.h:583: multiple definition of `__vector_5'
    TempHumidOnMotion.cpp.o:/Arduino/TempHumidOnMotion.ino:73: first defined here
    collect2: error: ld returned 1 exit status
    Erreur lors de la compilation.

  • Contest Winner

    @scalz
    Hi, regarding you first qeustion I'll copy somehting from my Project Documentation from the Wall Remote below.
    I dont really understand your second question. If you enable the interrupts on pin5 and pin6, the interrupt will always be triggered if the pin changes its voltage level... It can obviously not discover what caused the voltage level only that it did.. But I fear I do not understand exactly what you mean..

    To wake up the controller from sleep mode, which is used to save power, the PinChange Interrupts
    have been used, but Arduino compiles also the MyGateway.cpp where PinChange interrupts also
    have been used. Because every Interrupt Vector is only allowed to be once in the compiled code this
    is a problem.
    However the workaround for this is to rename the “MyGateway.cpp” from the “{Arduino
    Sketchbooks}\libraries\MySensors” into something the compiler does not try to compile e.g.
    “MyGateway.cpp.nolib”. Remind to undo this renaming if you want to compile a MySensors
    Gateway!
    You find the {Arduino Sketchbooks} location by “File-Prefernces” in the Arduino IDE.
    When the files have been renamed it is possible to compile the WallRemote sketch. When
    everything is connected like shown above you can also download the sketch to the hardware. For
    the download the correct Board and COM port must be selected. Make sure the
    “Tools->Board->Arduino Pro or ProMini (3.3V, 3.6864 MHz) w/ ATmega328” is selected. This
    board has been added earlier to the Arduino environment in section 2.7.


  • Hardware Contributor

    Hi.
    @Dirk_H I should try before. I renamed Mygateway.cpp and it works well now.
    Thx for your help.


  • Admin

    Or use development branch where this dependency has been removed from the library.


Log in to reply
 

Suggested Topics

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts