Hi Nick, here is the toggle code:
#include <MsTimer2.h>
#include "dcf77_demodulator.h"
const uint8_t dcf77_sample_pin = 19; // A5
const uint8_t dcf77_analog_sample_pin = 5;
void process_one_sample() {
digitalWrite(17,HIGH);
const uint8_t sampled_data = analogRead(dcf77_analog_sample_pin)>200? 1: 0;
DCF77_Demodulator::detector(sampled_data);
digitalWrite(17,LOW);
}
void setup() {
Serial.begin(115200);
pinMode(dcf77_sample_pin, INPUT);
digitalWrite(dcf77_sample_pin, HIGH);
DCF77_Demodulator::setup();
MsTimer2::set(1, process_one_sample);
MsTimer2::start();
// disable timer0
TIMSK0 = 0;
pinMode(17, OUTPUT);
}
void loop() {
DCF77_Demodulator::debug();
DCF77_Decoder::debug();
}
Because I was lazy I just took a picture of the attached LED with the same trick as described here: Shutter Speed | Blinkenlight (see attachment).
The ticks are of course 1000us apart. As you can clearly see the duty cycle is below 50%. So this should not be causing the issue. I also can not see any significant jitter.
