Go Down

Topic: PinChangeInt.h not compiling (Read 1 time) previous topic - next topic

S_v_L

Hello,

I recently bought the Arduino 101, because I'm making a quadcopter and wanted an upgrade from the UNO. With the UNO I used the PCMSK bit to setup the pin change interrupts. The main page of Arduino states that with the Arduino 101, many more pins are capable of detecting a change. So I decided to give PinChangeInt.h a shot.

I downloaded the newest PinChangeInt.h from the github repo, put it in the library folder, and tried to compile this code:

Code: [Select]
#include <PinChangeInt.h>

void setup() {}

void loop() {}


It didn't run. Because of this I have two questions:
1. What to do to make PinChangeInt.h work?
2. Is there another way to use all the pins for interrupts, without using the PinChangeInt.h library, just like PCMSK for the UNO?

 This is the error I got:

Code: [Select]
In file included from /tmp/arduino_6365aa5d04f4bf8cba3d8c596e12cdd6/sketch_jan04a.ino:1:0:
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: In constructor 'PCintPort::PCintPort(int, int, volatile uint8_t&)':
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:196:39: error: 'portInputRegister' was not declared in this scope
  portInputReg(*portInputRegister(index)),
                                       ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: At global scope:
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:325:32: error: 'PCMSK0' was not declared in this scope
 PCintPort portB=PCintPort(2, 0,PCMSK0); // port PB==2  (from Arduino.h, Arduino version 1.0)
                                ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:328:32: error: 'PCMSK1' was not declared in this scope
 PCintPort portC=PCintPort(3, 1,PCMSK1); // port PC==3  (also in pins_arduino.c, Arduino version 022)
                                ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:331:32: error: 'PCMSK2' was not declared in this scope
 PCintPort portD=PCintPort(4, 2,PCMSK2); // port PD==4
                                ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: In member function 'void PCintPort::enable(PCintPort::PCintPin*, PCIntvoidFuncPtr, uint8_t)��:
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:408:2: error: 'PCICR' was not declared in this scope
  PCICR |= PCICRbit;
  ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: In static member function 'static int8_t PCintPort::attachInterrupt(uint8_t, PCIntvoidFuncPtr, int)':
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:459:18: error: 'NOT_A_PORT' was not declared in this scope
  if ((portNum == NOT_A_PORT) || (userFunc == NULL)) return(-1);
                  ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: In static member function 'static void PCintPort::detachInterrupt(uint8_t)':
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:478:17: error: 'NOT_A_PORT' was not declared in this scope
  if (portNum == NOT_A_PORT) return;
                 ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:484:22: error: 'SREG' was not declared in this scope
    uint8_t oldSREG = SREG;
                      ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:485:8: error: 'cli' was not declared in this scope
    cli(); // disable interrupts
        ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:497:31: error: 'PCICR' was not declared in this scope
    if (port->portPCMask == 0) PCICR &= ~(port->PCICRbit);
                               ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: In member function 'void PCintPort::PCint()':
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:564:11: error: 'PCIFR' was not declared in this scope
   pcifr = PCIFR & PCICRbit;
           ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h: At global scope:
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:594:4: error: expected constructor, destructor, or type conversion before '(' token
 ISR(PORTBVECT) {
    ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:604:4: error: expected constructor, destructor, or type conversion before '(' token
 ISR(PORTCVECT) {
    ^
/home/sander/drone/Arduino-Quadcopter/libraries/PinChangeInt/PinChangeInt.h:614:4: error: expected constructor, destructor, or type conversion before '(' token
 ISR(PORTDVECT){
    ^
exit status 1
Error compiling.



I have the newest Arduino IDE 1.6.7 installed, and uploading other sketches to the board works just fine.
Thank you!

facchinm

Hi S_v_L,
UNO and 101 are completely different boards with different architectures.
Curie chip on 101 is much more capable than AVR328 mounted on UNO, so every pin has interrupt capabilities without any need of special libraries.
Please note that every AVR-specific library (like TimerOne) will not work with 101 but there are replacements available and the documentation is growing.

S_v_L

I have tested it and I can just use attachInterrupt without including PinChangeInt.h

One question left though, I saw it on the main page but I'm just asking for total clarity. Can I safely read a signal of 5V? Better be safe than sorry frozen!

Thank you very much for your quick response!

facchinm

All pins are protected from 5V overvoltage so you can safely read a 5V signal (just make sure it's not a 20V one  ;) )

Go Up