alternative to attachInterrupt() on Teensy 3.6

Status
Not open for further replies.

atok28

Member
Hello

Im trying to trigger an ADC read based on a pin changing state using an interrupt.
After a lot of debugging a bit Ive come to the realization that not even the most basic code using interrupts does not work for me, neither dose the example in the arduino documentation for the attachInterrupt() function.

For example the code below found on the forums will never execute the statement in the interrupt(I tried supplying a square wave and short pulses). Im not sure if Im missing something or is it possible that this is caused by damage to the board? Are there alternative ways of implementing pin interrupts? I cant run the intervalTimer() either (the interrupt statements dont seem to execute) but using PDB interrupts with the ADC works.


(https://forum.pjrc.com/threads/2490...ovide-guidance?p=40284&viewfull=1#post40284):
Code:
#define PinInt1 23

void setup() {
  Serial.begin(115200);
  pinMode(PinInt1, INPUT_PULLUP); // sets the digital pin as output
  attachInterrupt(PinInt1, isrService, FALLING); // interrrupt 1 is data ready
}

void loop()
{
  delay(1000);
  Serial.println("Running");
}

// watermark generates this interrupt
void isrService()
{
  Serial.println("At ISR0");
}
 
Last edited by a moderator:
I tried the code, and it works without problems.
Code:
[COLOR=#ff8c00][/COLOR]pinMode(PinInt1,[COLOR=#ff8c00] [B]INPUT_PULLUP[/B][/COLOR]); // sets the digital pin as [COLOR=#ff8c00][B]input[/B][/COLOR]

The only potential problem with your code is, that it may work better with INPUT_PULLUP - that depends on the connection to that pin.
I changed it to INPUT_PULLUP, took a simple wire, connected it to PIn23, and touched GND with the other end.
Take a look on the printed card, where Pin23 is.
 
Last edited:
Status
Not open for further replies.
Back
Top