Teensy 3.6 Interrupts

Status
Not open for further replies.
I am new to Teensy.

I have a Hall Effect sensor: https://www.amazon.com/gp/product/B00W029QYC ,
with the DOUT pin connected to pin23 of the Teensy,
Vcc is connectd to 3.3V on the Teensy.

My Code:
Code:
const byte Column_One_Pin  = 23;
const byte debugpin        = 21;


void setup() {  

pinMode(Column_One_Pin,  INPUT);	//_PULLUP);

attachInterrupt(Column_One_Pin,Column_One_Int,FALLING);

pinMode(debugpin,	OUTPUT);
digitalWrite(debugpin,LOW);
}

void loop() {
}

void Column_One_Int()
{
	digitalWrite(debugpin,HIGH);
	delayMicroseconds(10);
	digitalWrite(debugpin,LOW);
}

When I wave a magnet over the sensor, the interrupt latency is huge > 100uS !!

interruptTest.png

Can anyone tell me what I'm missing.
 
Last edited by a moderator:
I tried it just now and could not reproduce anything like 100 us latency.

Since I don't have your hardware, I used analogWrite to create a PWM waveform on pin 22, which I connected to pin 23.

Here's what my oscilloscope sees on pins 21 and 23.

file.png

The blue pulse is 10 us wide, and it starts less than 1 us after the falling edge on pin 23.

Here is the exact code I ran for this test.

Code:
const byte Column_One_Pin  = 23;
const byte debugpin        = 21;


void setup() {
  pinMode(Column_One_Pin,  INPUT);  //_PULLUP);
  attachInterrupt(Column_One_Pin, Column_One_Int, FALLING);
  pinMode(debugpin, OUTPUT);
  digitalWrite(debugpin, LOW);
  analogWriteFrequency(22, 1000);
  analogWrite(22, 128);
}

void loop() {
}

void Column_One_Int()
{
  digitalWrite(debugpin, HIGH);
  delayMicroseconds(10);
  digitalWrite(debugpin, LOW);
}
 
I copy-n-pasted your code into Arduino 1.8.10 IDE.
Works as described.

The Hall Effect sensor is causing the problem (??).
 
Last edited:
The Hall Effect sensor is causing the problem (??).

Very difficult to say. Seems unlikely the falling edge could be so slow that the logic analyzer and Teensy's pin detect the change 100 us apart. But something "analog" might be happening in those 100 microseconds?
 
Maybe the LM393 is introducing delay? I have a simple Hall-effect sensor. When hooked to a T3.5 with 10K pullup on output to 3v3 (also tried 5v), I see 3v3 on the output pin. With the magnet nearby it goes to 0v. I can count "ticks" in attachInterrupt().

Do you have data sheet and/or schematic for your sensor/PCB?

Here is scope shot of my Hall-effect sensor on T3.6 (3v3 to sensor)
hall.png
The blue is hall pin 23 falling, and the yellow is the pulse rising 610 ns after the falling hall signal. If you use digitalWriteFast(), the delay is reduced to 520 ns. So no big delay with my basic Hall sensor.
 
Last edited:
Yes, the sensor was the problem.
I did not realize the lm393 was so slow.

I added an 74C902 to the output of the lm393:
interruptTest_2.png

Much better !

Thanks all.
 
Before I move on too fast,
How would I set the interrupt priority on pin 23 ?
How would I check what the priority level is ?

Thanks again.
 
Status
Not open for further replies.
Back
Top