Hardware Interrupt?

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
JohnKnoll
 
Posts: 2
Joined: Sun May 15, 2022 9:29 pm

Hardware Interrupt?

Post by JohnKnoll »

I have a project where I'm using a Trinket M0 to count logic pulses coming in from another microcontroller, a Teensy 4.1. Both devices are powered from the same source and their grounds are connected.

I'm feeding the signal from the Teensy to pin 1 , and attaching an interrupt routine to that pin:

volatile int motorpositioncounter1;
int motorpos;
const int xstepPin = 1;
const int xdirPin = 2;

/*************************************************************************************/

void countpulse1(void)
{
if (digitalRead(xdirPin)) motorpositioncounter1--;
else motorpositioncounter1++;
}

/*************************************************************************************/

void setup()
{
pinMode(xstepPin, INPUT);
pinMode(xdirPin, INPUT);

// setup interrupt to count pulses
motorpositioncounter1 = 0;
attachInterrupt(digitalPinToInterrupt(xstepPin), countpulse1, FALLING);

motorpos = 0;
}

/*************************************************************************************/
void loop()
{

// Get the motor position.
noInterrupts();
motorpos = motorpositioncounter1;
interrupts();

// display it
DisplayMotorPosition(motorpos);
delay(10);
}

/*************************************************************************************/


This compiles and runs without error, but the pulses are not getting counted. This exact same setup works perfectly with a Teensy LC, but doesn't work with the Trinket M0. The pinout card indicates that I should be able to trigger hardware interrupts on pin1 in this manner, but it doesn't appear to be working. Is there something I'm not doing right here?

Thanks!

User avatar
JohnKnoll
 
Posts: 2
Joined: Sun May 15, 2022 9:29 pm

Re: Hardware Interrupt?

Post by JohnKnoll »

Sorry, false alarm. It is working. Like an idiot I was hooked up to the wrong pin on the Teensy.

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”