Croc
Member
Hello,
for my first post here, i would like to thanks everyone for the help and tips, and of course Paul for the board development.
I bought my first Teensy (4.0) a month ago, and i've tested a lot of my previous works from my Arduino experience.
One of my most useful program/device is a 6 channels Pulse Generator, which generates 6 independant pulses (width + delay) triggered from an external trigger signal. That is used for triggering camera, valve, or any device in an experimental laboratory, for example.
Now trying to re-use my old code into my new Teensy 4.0, but you know, with the high speed it provides and hoping a jitter far below the µs.
With my UNO board (16 MHz) i achieved a 1 to 2 µs resolution, coz of the minimum clock cycles needed for some operation. I was using the direct port access, and the ISR() interrupt, then compare the timer value with ISR(TIMER1_COMPA_vect), playing with ISR (TIMER1_OVF_vect), use masks/flags, etc... i'm pretty sure you know that world.
But it's impossible to use the "old" ISR() command with that Teensy...
even with this simpliest and useless code, i'm having compilation error pointing on the ISR() line. (expected constructor, destructor, or type conversion before '(' token)
That basic example comes from here https://www.pjrc.com/teensy/interrupts.html
I've also tested the TeensyTimerTool, with that example : https://github.com/luni64/TeensyTimerTool/wiki/Callbacks#functors-as-callback-objects
There are few problems that i would like to avoid :
- the t1/t2.trigger() are executed one after the other, and t2 has to wait the end of t1. I can't start t2 during the middle of t1. (no overlap = no multichannel)
- we can't use zero as trigger(delay). The minimum delay is 1 µs.
- resolution is 1 µs minimum, not tick from timer/clock.
That library is very useful, but probably not in my case.
I really want the accuracy way (correct me if i'm wrong) of :
- interrupt of one pin, from where the external trigger comes
- set the timer to "zero"
- compare timer (or waiting for) value until i've to LOW/HIGH one (or multiple) output pin
- compare/wait for the next LOW/HIGH/channel, etc...
- end/restart the interrupt routine, to catch the next external trig.
In advance, thanks for your help/comments !
for my first post here, i would like to thanks everyone for the help and tips, and of course Paul for the board development.
I bought my first Teensy (4.0) a month ago, and i've tested a lot of my previous works from my Arduino experience.
One of my most useful program/device is a 6 channels Pulse Generator, which generates 6 independant pulses (width + delay) triggered from an external trigger signal. That is used for triggering camera, valve, or any device in an experimental laboratory, for example.
Now trying to re-use my old code into my new Teensy 4.0, but you know, with the high speed it provides and hoping a jitter far below the µs.
With my UNO board (16 MHz) i achieved a 1 to 2 µs resolution, coz of the minimum clock cycles needed for some operation. I was using the direct port access, and the ISR() interrupt, then compare the timer value with ISR(TIMER1_COMPA_vect), playing with ISR (TIMER1_OVF_vect), use masks/flags, etc... i'm pretty sure you know that world.
But it's impossible to use the "old" ISR() command with that Teensy...
even with this simpliest and useless code, i'm having compilation error pointing on the ISR() line. (expected constructor, destructor, or type conversion before '(' token)
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
ISR(TIMER0_OVF_vect)
{
/* Timer 0 overflow */
}
That basic example comes from here https://www.pjrc.com/teensy/interrupts.html
I've also tested the TeensyTimerTool, with that example : https://github.com/luni64/TeensyTimerTool/wiki/Callbacks#functors-as-callback-objects
Code:
(...)
OneShotTimer t1, t2;
void setup()
{
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
t1.begin(PulseGenerator(1, 5)); // 5µs pulse on pin 1
t2.begin(PulseGenerator(2, 10)); //10µs pulse on pin 2
}
void loop()
{
t1.trigger(1'000); // delay 1ms
t2.trigger(500); // delay 500 µs
delay(10);
}
- the t1/t2.trigger() are executed one after the other, and t2 has to wait the end of t1. I can't start t2 during the middle of t1. (no overlap = no multichannel)
- we can't use zero as trigger(delay). The minimum delay is 1 µs.
- resolution is 1 µs minimum, not tick from timer/clock.
That library is very useful, but probably not in my case.
I really want the accuracy way (correct me if i'm wrong) of :
- interrupt of one pin, from where the external trigger comes
- set the timer to "zero"
- compare timer (or waiting for) value until i've to LOW/HIGH one (or multiple) output pin
- compare/wait for the next LOW/HIGH/channel, etc...
- end/restart the interrupt routine, to catch the next external trig.
In advance, thanks for your help/comments !