Hi All,
Newbie Arduino Uno user here.
I've gone through the Timers tutorials on gammon's forum and successfully implemented the "do something every x us jitter-free" sketch, but I still can't get something to happen every trigger, jitter-free, with sub-us resolution. The closest I have come is the following sketch:
#include <util/delay.h>
#include <avr/sleep.h>
const byte interruptPin = 2;
const byte outputPin = 12;
double testDel = 10;
void trigger () {
_delay_us(testDel);
PORTB |= B00010000; // pin12 high
_delay_us(testDel);
PORTB = B00000000;
}
void setup() {
DDRB |= B11111111; // digital pins -,-,13,12,11,10,9,8 as output
DDRD = B00000000; // digital pins 7,6,5,4,3,2,1,0 as input
attachInterrupt(digitalPinToInterrupt(interruptPin),trigger,RISING);
set_sleep_mode (SLEEP_MODE_IDLE);
}
void loop() {
sleep_mode ();
}
It's almost exactly what I need, but there still is some jitter, and I don't know where it could be coming from. Any ideas of where to look to reduce it?
Thanks in advance