STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
check_pulse.cpp
Go to the documentation of this file.
1
// #include <ADS126X.h>
2
// #include <SPI.h>
3
// #include <Arduino.h>
4
5
// #define CS 37
6
// #define SCLK 13
7
// #define MISO 41
8
// #define MOSI 5
9
10
// ADS126X adc;
11
12
// void setPulseMode(void);
13
14
// // ADS1263 register addresses and commands
15
// static const uint8_t CMD_RREG = 0x20;
16
// static const uint8_t REG_MODE0 = 0x03;
17
18
// static const uint8_t CMD_WREG = 0x40;
19
20
// uint8_t readReg(uint8_t reg) {
21
// SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE1));
22
// digitalWrite(CS, LOW);
23
// SPI.transfer(CMD_RREG | (reg & 0x1F));
24
// SPI.transfer(0x00); // read 1 byte
25
// uint8_t val = SPI.transfer(0x00);
26
// digitalWrite(CS, HIGH);
27
// SPI.endTransaction();
28
// return val;
29
// }
30
31
// void setup() {
32
// Serial.begin(115200);
33
// SPI.begin(SCLK, MISO, MOSI, CS);
34
// adc.begin(CS);
35
36
// uint8_t mode0 = readReg(REG_MODE0);
37
// bool isPulse = (mode0 & 0x10) != 0;
38
// sys_delay_ms(2000);
39
// Serial.print("MODE0 = 0x");
40
// Serial.println(mode0, HEX);
41
// Serial.print("RUNMODE: ");
42
// Serial.println(isPulse ? "Pulse (one-shot)" : "Continuous");
43
44
// setPulseMode();
45
// }
46
47
// void loop() {
48
// uint8_t mode0 = readReg(REG_MODE0);
49
// bool isPulse = (mode0 & 0x10) != 0;
50
51
// Serial.print("MODE0 = 0x");
52
// Serial.println(mode0, HEX);
53
// Serial.print("RUNMODE: ");
54
// Serial.println(isPulse ? "Pulse (one-shot)" : "Continuous");
55
// }
56
57
// void setPulseMode() {
58
// // Read current MODE0
59
// uint8_t mode0 = readReg(REG_MODE0);
60
61
// // Set RUNMODE bit (bit 4) and clear CHOP bits (bits 1:0)
62
// mode0 = (mode0 | 0x10) & ~0x03;
63
64
// // Write back
65
// SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE1));
66
// digitalWrite(CS, LOW);
67
// SPI.transfer(CMD_WREG | (REG_MODE0 & 0x1F)); // WREG + address
68
// SPI.transfer(0x00); // writing 1 byte
69
// SPI.transfer(mode0);
70
// digitalWrite(CS, HIGH);
71
// SPI.endTransaction();
72
73
// // Confirm
74
// uint8_t check = readReg(REG_MODE0);
75
// Serial.print("MODE0 now = 0x");
76
// Serial.println(check, HEX);
77
// Serial.println((check & 0x10) ? "Pulse mode set" : "Still continuous");
78
// }
firmware
ADC_Testing
Noise_Characterization
test
Old
check_pulse.cpp
Generated by
1.15.0