DIY Auto-Correlator 1.0
Auto-Correlator Card implementation using Teensy 4.x microcontrollers.
featureline2.hpp
Go to the documentation of this file.
1#include <Arduino.h>
2#include <imxrt.h>
3
4#pragma once
5#include "global.hpp"
6#include "./../code/hardware/qtmr1.hpp"
7//#include "./../code/hardware/errors.hpp"
8#include "./../code/hardware/ledpanel.hpp"
9#include "./../code/software/multi_tau.hpp"
10#include "./../code/hardware/qtmr1.hpp"
11
12
14{
15
16 //0. Start-up Indicator
17 LEDPanel.set(LED_BLUE);
18 LEDPanel.toggle_twice(LED_BLUE, 500);
19 LEDPanel.toggle_twice(LED_BLUE, 500);
20
21
22 //1. Set Serial Sampling Time
23 Serial.begin(115200);
24 while(!Serial)
25 {}
26 extern uint32_t serial_max_count(double Gate_time_us, double Serial_out_time_m);
27 SerialOut_After = 1000000;
28
29
30 // 2. Init QTMR
31 TTL_c.init();
33
34 //3. Exit Startup Indicator
36
37 asm volatile ("dsb");
38
39} // End of setup_interarrival()
40
41
43{
44 Update_count = 0;
45 Counter_val = 0;
46 TTL_c.start();
47
48 while(1)
49 {
50 //while(IATimer.PCount < SerialOut_After)
51 //{
52 //IATimer.measure();
53 //Update_count++;
54 //}
55
56 // Serial Output Block
57
58 //1. Sync Code
59 #if ENABLE_SYNC_CODE == 1
60 Serial.write((uint8_t*)&(sync_code), sizeof(int32_t));
61 #endif
62
63 //2. Stats Output
64 Counter_val = IMXRT_TMR1.CH[0].CNTR;
65 IMXRT_TMR1.CH[0].CNTR = 0;
66 Serial.write((uint8_t*)&(Counter_val), sizeof(counter_t));
67
68 // Serial output of stat struct
69 //IATimer.output();
70
71
72 Update_count = 0;
73
74
75 }
76} // End of loop_interarrival()
void init_pins() __attribute__((always_inline))
Sets the Primary and Secondary inputs for Capture Mode, routed through XBAR. Reference XBAR and IOMUX...
Definition: qtmr1.hpp:185
void start() __attribute__((always_inline))
Starts up-counting from the set counter value.
Definition: qtmr1.hpp:24
void init() __attribute__((always_inline))
Definition: qtmr1.hpp:107
void loop_interarrival()
Definition: featureline2.hpp:42
void setup_interarrival()
Definition: featureline2.hpp:13
const double Gate_time_us
Serial output is done after these many updates (default → overriden in the setup function).
Definition: global.cpp:29
TMR1Controller TTL_c
TTL_c Resource.
Definition: global.cpp:19
uint32_t SerialOut_After
Definition: global.cpp:28
const int32_t sync_code
Gate time precision error due to finite precision of timers.
Definition: global.cpp:31
volatile unsigned int Update_count
Stores the number of updates made on the correlator channels since the last serialout.
Definition: global.cpp:25
volatile counter_t Counter_val
Stores the value read from the counter.
Definition: global.cpp:23
LEDSet< 5 > LEDPanel({LED_BUILTIN, LED_RED, LED_GREEN, LED_WHITE, LED_BLUE})
const int LED_WHITE
Definition: pins.hpp:9
const int LED_BLUE
Definition: pins.hpp:7
uint32_t counter_t
Data type received from the pulse counter. It is the fundamental type used for representing series da...
Definition: types.hpp:7
uint32_t serial_max_count(double Gate_time_us, double Serial_out_time_ms)
Definition: utilities.cpp:7