ADXL362 FIFO Contents Miss Activity Capture in Triggered Mode

I am using ADXL362 in triggered mode and goal is to capture an impact event (may bump up to 372 but first want to undertand interface on 362). Like many posters here I am seeing a delay in the capture that I am having difficulty correcting for. Unfortunately the forums often seem to address this off line or the Analog support response is missing so I cant see clearly how others have resolved this.

Issue is when we capture data to FIFO triggered mode with linked mode set that I expect it to be like oscilloscope single trigger such that ON ACT interrupt (Or Awake bit) I can read FIFO then or slightly later to see the impact event in FIFO. I assume trigger is AWAKE and one it fills up to level in SAMPLES it holds until next event.

What actually happens is the data in the immediate FIFO read and slight delayed read appears flat however a FIFO read for the next subsequent activity interrupt often shows the imapct event ( I can make to sequetial events very differnt like tip over vs light tap).

I have tried waiting a fixed time after interrupt between 100-500ms. I have looked for overrun bit before reading FIFO, I have currently wait for inact bit after act bit to wait to read fifo but never a consistent capture of impact.

What is the correct way to configure this?

A couple of things to note about my output below:
1.) this Arduino sketch prints fifo on awake even but waits to read unttil inact bit after the act. There are verbose notes throughout
2.) 2 impacts here....note 1st one tips the unit over and 2nd one is just a tap ...you can see real time reads of xyz on wither side of event to see what oritentation it was in pere and post fifo read.
3.) the fifo since its running 6 byes per sample will be misaligned for first read or 2 but then seems to find steady alignment such that sample one is x (00) next is y (01) next is z (02) but thats not true until we roll over.
4.) strangely the number of FIFO entries comes out to 513 at times...is this correct?
5.) note in 2nd event...buffer entry 169 caught one sample of tip over event but why does it appear at end and where is event samples on either side and why second capture?

Here is my output from the adxl362:

STARTUP REGISTER READ JUST PRE MEASUREMENT MODE
_____________________________________________________________________________
X/Y/Z= 0.00/0.00/0.00 Temp:107.69 Pin 13:1 STAT:40 FLTER_CTL:5 PWR_CTL:0 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:0 loop:0 millis():56

STARTUP REGISTER READ JUST POST MEASUREMENT MODE
_____________________________________________________________________________

X/Y/Z= -0.02/-1.16/0.14 Temp:73.18 Pin 13:1 STAT:42 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:63 loop:0 millis():82

0
1
JUST_MOTION is true.
loop iteration= 0
0
X/Y/Z= -0.03/-1.13/0.14 Temp:73.41 Pin 13:1 STAT:42 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:87 loop:0 millis():100

Waiting for Inact bit to set

X/Y/Z= -0.03/-1.16/0.13 Temp:73.53 Pin 13:1 STAT:42 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:114 loop:0 millis():117

Waiting for Inact bit to set

X/Y/Z= -0.01/-1.14/0.16 Temp:73.41 Pin 13:0 STAT:26 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:512 loop:0 millis():682

Read 512 (2-byte) samples, after reading that out into an array shift out any samples not part of a triplet measurement set off the front of the array (oldest)

X/Y/Z= -0.03/-1.15/0.12 Temp:73.06 Pin 13:0 STAT:2 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:3 loop:0 millis():710

Print buffer also looking at axis identificaiton bits
0 02 00 01

x=;+0100;y=;-0020;z=;-1153;FIFO_BUFF PLACE:;00

6 02 00 01

x=;+0120;y=;-0029;z=;-1156;FIFO_BUFF PLACE:;01

12 02 00 01

x=;+0136;y=;-0025;z=;-1128;FIFO_BUFF PLACE:;02

18 02 00 01

x=;+0142;y=;-0024;z=;-1162;FIFO_BUFF PLACE:;03

24 02 00 01

x=;+0140;y=;-0025;z=;-1154;FIFO_BUFF PLACE:;04

30 02 00 01

x=;+0136;y=;-0025;z=;-1165;FIFO_BUFF PLACE:;05

36 02 00 01

x=;+0115;y=;-0036;z=;-1154;FIFO_BUFF PLACE:;06

42 02 00 01

x=;+0113;y=;-0032;z=;-1133;FIFO_BUFF PLACE:;07

48 02 00 01

x=;+0135;y=;-0023;z=;-1128;FIFO_BUFF PLACE:;08

54 02 00 01

x=;+0144;y=;-0025;z=;-1137;FIFO_BUFF PLACE:;09

60 02 00 01

x=;+0131;y=;-0025;z=;-1149;FIFO_BUFF PLACE:;010

66 02 00 01

x=;+0116;y=;-0029;z=;-1157;FIFO_BUFF PLACE:;011

72 02 00 01

x=;+0102;y=;-0031;z=;-1149;FIFO_BUFF PLACE:;012

78 02 00 01

x=;+0131;y=;-0042;z=;-1145;FIFO_BUFF PLACE:;013

84 02 00 01

x=;+0144;y=;-0026;z=;-1138;FIFO_BUFF PLACE:;014

90 02 00 01

x=;+0156;y=;-0028;z=;-1160;FIFO_BUFF PLACE:;015

96 02 00 01

x=;+0132;y=;-0028;z=;-1160;FIFO_BUFF PLACE:;016

102 02 00 01

x=;+0135;y=;-0040;z=;-1153;FIFO_BUFF PLACE:;017

108 02 00 01

x=;+0147;y=;-0032;z=;-1140;FIFO_BUFF PLACE:;018

114 02 00 01

x=;+0124;y=;-0036;z=;-1145;FIFO_BUFF PLACE:;019

120 02 00 01

x=;+0145;y=;-0041;z=;-1140;FIFO_BUFF PLACE:;020

126 02 00 01

x=;+0120;y=;-0031;z=;-1160;FIFO_BUFF PLACE:;021

132 02 00 01

x=;+0112;y=;-0029;z=;-1152;FIFO_BUFF PLACE:;022

138 02 00 01

x=;+0131;y=;-0025;z=;-1169;FIFO_BUFF PLACE:;023

144 02 00 01

x=;+0137;y=;-0009;z=;-1136;FIFO_BUFF PLACE:;024

150 02 00 01

x=;+0156;y=;-0023;z=;-1162;FIFO_BUFF PLACE:;025

156 02 00 01

x=;+0160;y=;-0025;z=;-1169;FIFO_BUFF PLACE:;026

162 02 00 01

x=;+0121;y=;-0032;z=;-1154;FIFO_BUFF PLACE:;027

168 02 00 01

x=;+0112;y=;-0025;z=;-1145;FIFO_BUFF PLACE:;028

174 02 00 01

x=;+0131;y=;-0028;z=;-1137;FIFO_BUFF PLACE:;029

180 02 00 01

x=;+0135;y=;-0016;z=;-1136;FIFO_BUFF PLACE:;030

186 02 00 01

x=;+0127;y=;-0017;z=;-1144;FIFO_BUFF PLACE:;031

192 02 00 01

x=;+0140;y=;-0018;z=;-1138;FIFO_BUFF PLACE:;032

198 02 00 01

x=;+0147;y=;-0029;z=;-1157;FIFO_BUFF PLACE:;033

204 02 00 01

x=;+0111;y=;-0025;z=;-1149;FIFO_BUFF PLACE:;034

210 02 00 01

x=;+0129;y=;-0024;z=;-1135;FIFO_BUFF PLACE:;035

216 02 00 01

x=;+0144;y=;-0020;z=;-1137;FIFO_BUFF PLACE:;036

222 02 00 01

x=;+0148;y=;-0033;z=;-1143;FIFO_BUFF PLACE:;037

228 02 00 01

x=;+0123;y=;-0024;z=;-1152;FIFO_BUFF PLACE:;038

234 02 00 01

x=;+0102;y=;-0031;z=;-1152;FIFO_BUFF PLACE:;039

240 02 00 01

x=;+0102;y=;-0033;z=;-1138;FIFO_BUFF PLACE:;040

246 02 00 01

x=;+0111;y=;-0031;z=;-1144;FIFO_BUFF PLACE:;041

252 02 00 01

x=;+0167;y=;-0033;z=;-1149;FIFO_BUFF PLACE:;042

258 02 00 01

x=;+0156;y=;-0025;z=;-1161;FIFO_BUFF PLACE:;043

264 02 00 01

x=;+0135;y=;-0020;z=;-1156;FIFO_BUFF PLACE:;044

270 02 00 01

x=;+0143;y=;-0029;z=;-1160;FIFO_BUFF PLACE:;045

276 02 00 01

x=;+0127;y=;-0032;z=;-1138;FIFO_BUFF PLACE:;046

282 02 00 01

x=;+0143;y=;-0025;z=;-1153;FIFO_BUFF PLACE:;047

288 02 00 01

x=;+0124;y=;-0033;z=;-1146;FIFO_BUFF PLACE:;048

294 02 00 01

x=;+0113;y=;-0031;z=;-1153;FIFO_BUFF PLACE:;049

300 02 00 01

x=;+0111;y=;-0026;z=;-1156;FIFO_BUFF PLACE:;050

306 02 00 01

x=;+0131;y=;-0031;z=;-1157;FIFO_BUFF PLACE:;051

312 02 00 01

x=;+0135;y=;-0016;z=;-1133;FIFO_BUFF PLACE:;052

318 02 00 01

x=;+0135;y=;-0028;z=;-1136;FIFO_BUFF PLACE:;053

324 02 00 01

x=;+0145;y=;-0016;z=;-1133;FIFO_BUFF PLACE:;054

330 02 00 01

x=;+0127;y=;-0024;z=;-1161;FIFO_BUFF PLACE:;055

336 02 00 01

x=;+0127;y=;-0029;z=;-1154;FIFO_BUFF PLACE:;056

342 02 00 01

x=;+0119;y=;-0033;z=;-1152;FIFO_BUFF PLACE:;057

348 02 00 01

x=;+0124;y=;-0016;z=;-1145;FIFO_BUFF PLACE:;058

354 02 00 01

x=;+0135;y=;-0025;z=;-1168;FIFO_BUFF PLACE:;059

360 02 00 01

x=;+0121;y=;-0016;z=;-1146;FIFO_BUFF PLACE:;060

366 02 00 01

x=;+0159;y=;-0029;z=;-1167;FIFO_BUFF PLACE:;061

372 02 00 01

x=;+0144;y=;-0029;z=;-1161;FIFO_BUFF PLACE:;062

378 02 00 01

x=;+0120;y=;-0036;z=;-1162;FIFO_BUFF PLACE:;063

384 02 00 01

x=;+0104;y=;-0020;z=;-1137;FIFO_BUFF PLACE:;064

390 02 00 01

x=;+0137;y=;-0040;z=;-1133;FIFO_BUFF PLACE:;065

396 02 00 01

x=;+0143;y=;-0021;z=;-1128;FIFO_BUFF PLACE:;066

402 02 00 01

x=;+0111;y=;-0034;z=;-1137;FIFO_BUFF PLACE:;067

408 02 00 01

x=;+0100;y=;-0032;z=;-1153;FIFO_BUFF PLACE:;068

414 02 00 01

x=;+0134;y=;-0023;z=;-1161;FIFO_BUFF PLACE:;069

420 02 00 01

x=;+0116;y=;-0024;z=;-1143;FIFO_BUFF PLACE:;070

426 02 00 01

x=;+0152;y=;-0024;z=;-1146;FIFO_BUFF PLACE:;071

432 02 00 01

x=;+0158;y=;-0036;z=;-1160;FIFO_BUFF PLACE:;072

438 02 00 01

x=;+0152;y=;-0025;z=;-1169;FIFO_BUFF PLACE:;073

444 02 00 01

x=;+0132;y=;-0036;z=;-1145;FIFO_BUFF PLACE:;074

450 02 00 01

x=;+0135;y=;-0036;z=;-1140;FIFO_BUFF PLACE:;075

456 02 00 01

x=;+0152;y=;-0018;z=;-1129;FIFO_BUFF PLACE:;076

462 02 00 01

x=;+0148;y=;-0020;z=;-1150;FIFO_BUFF PLACE:;077

468 02 00 01

x=;+0153;y=;-0009;z=;-1165;FIFO_BUFF PLACE:;078

474 02 00 01

x=;+0140;y=;-0017;z=;-1154;FIFO_BUFF PLACE:;079

480 02 00 01

x=;+0135;y=;-0032;z=;-1141;FIFO_BUFF PLACE:;080

486 02 00 01

x=;+0135;y=;-0036;z=;-1145;FIFO_BUFF PLACE:;081

492 02 00 01

x=;+0144;y=;-0009;z=;-1130;FIFO_BUFF PLACE:;082

498 02 00 01

x=;+0121;y=;-0012;z=;-1160;FIFO_BUFF PLACE:;083

504 02 00 01

x=;+0127;y=;-0027;z=;-1145;FIFO_BUFF PLACE:;084

510 02 00 01

x=;+0112;y=;-0041;z=;-1145;FIFO_BUFF PLACE:;085

516 02 00 01

x=;+0116;y=;-0025;z=;-1132;FIFO_BUFF PLACE:;086

522 02 00 01

x=;+0103;y=;-0015;z=;-1140;FIFO_BUFF PLACE:;087

528 02 00 01

x=;+0127;y=;-0012;z=;-1138;FIFO_BUFF PLACE:;088

534 02 00 01

x=;+0145;y=;-0020;z=;-1165;FIFO_BUFF PLACE:;089

540 02 00 01

x=;+0142;y=;-0031;z=;-1151;FIFO_BUFF PLACE:;090

546 02 00 01

x=;+0134;y=;-0031;z=;-1137;FIFO_BUFF PLACE:;091

552 02 00 01

x=;+0123;y=;-0029;z=;-1130;FIFO_BUFF PLACE:;092

558 02 00 01

x=;+0143;y=;-0034;z=;-1160;FIFO_BUFF PLACE:;093

564 02 00 01

x=;+0136;y=;-0015;z=;-1165;FIFO_BUFF PLACE:;094

570 02 00 01

x=;+0132;y=;-0032;z=;-1166;FIFO_BUFF PLACE:;095

576 02 00 01

x=;+0113;y=;-0040;z=;-1146;FIFO_BUFF PLACE:;096

582 02 00 01

x=;+0127;y=;-0024;z=;-1130;FIFO_BUFF PLACE:;097

588 02 00 01

x=;+0131;y=;-0025;z=;-1128;FIFO_BUFF PLACE:;098

594 02 00 01

x=;+0137;y=;-0031;z=;-1143;FIFO_BUFF PLACE:;099

600 02 00 01

x=;+0108;y=;-0024;z=;-1145;FIFO_BUFF PLACE:;0100

606 02 00 01

x=;+0110;y=;-0025;z=;-1152;FIFO_BUFF PLACE:;0101

612 02 00 01

x=;+0115;y=;-0025;z=;-1151;FIFO_BUFF PLACE:;0102

618 02 00 01

x=;+0128;y=;-0028;z=;-1153;FIFO_BUFF PLACE:;0103

624 02 00 01

x=;+0156;y=;-0025;z=;-1145;FIFO_BUFF PLACE:;0104

630 02 00 01

x=;+0140;y=;-0025;z=;-1165;FIFO_BUFF PLACE:;0105

636 02 00 01

x=;+0120;y=;-0039;z=;-1146;FIFO_BUFF PLACE:;0106

642 02 00 01

x=;+0147;y=;-0030;z=;-1136;FIFO_BUFF PLACE:;0107

648 02 00 01

x=;+0129;y=;-0029;z=;-1129;FIFO_BUFF PLACE:;0108

654 02 00 01

x=;+0140;y=;-0045;z=;-1143;FIFO_BUFF PLACE:;0109

660 02 00 01

x=;+0119;y=;-0045;z=;-1141;FIFO_BUFF PLACE:;0110

666 02 00 01

x=;+0124;y=;-0025;z=;-1159;FIFO_BUFF PLACE:;0111

672 02 00 01

x=;+0110;y=;-0024;z=;-1149;FIFO_BUFF PLACE:;0112

678 02 00 01

x=;+0127;y=;-0016;z=;-1143;FIFO_BUFF PLACE:;0113

684 02 00 01

x=;+0152;y=;-0016;z=;-1140;FIFO_BUFF PLACE:;0114

690 02 00 01

x=;+0174;y=;-0029;z=;-1154;FIFO_BUFF PLACE:;0115

696 02 00 01

x=;+0144;y=;-0032;z=;-1152;FIFO_BUFF PLACE:;0116

702 02 00 01

x=;+0131;y=;-0031;z=;-1149;FIFO_BUFF PLACE:;0117

708 02 00 01

x=;+0131;y=;-0016;z=;-1135;FIFO_BUFF PLACE:;0118

714 02 00 01

x=;+0134;y=;-0031;z=;-1137;FIFO_BUFF PLACE:;0119

720 02 00 01

x=;+0134;y=;-0025;z=;-1135;FIFO_BUFF PLACE:;0120

726 02 00 01

x=;+0121;y=;-0016;z=;-1145;FIFO_BUFF PLACE:;0121

732 02 00 01

x=;+0092;y=;-0021;z=;-1140;FIFO_BUFF PLACE:;0122

738 02 00 01

x=;+0112;y=;-0029;z=;-1152;FIFO_BUFF PLACE:;0123

744 02 00 01

x=;+0107;y=;-0024;z=;-1144;FIFO_BUFF PLACE:;0124

750 02 00 01

x=;+0120;y=;-0029;z=;-1152;FIFO_BUFF PLACE:;0125

756 02 00 01

x=;+0135;y=;-0028;z=;-1140;FIFO_BUFF PLACE:;0126

762 02 00 01

x=;+0120;y=;-0032;z=;-1150;FIFO_BUFF PLACE:;0127

768 02 00 01

x=;+0136;y=;-0028;z=;-1169;FIFO_BUFF PLACE:;0128

774 02 00 01

x=;+0097;y=;-0026;z=;-1149;FIFO_BUFF PLACE:;0129

780 02 00 01

x=;+0103;y=;-0025;z=;-1136;FIFO_BUFF PLACE:;0130

786 02 00 01

x=;+0151;y=;-0028;z=;-1140;FIFO_BUFF PLACE:;0131

792 02 00 01

x=;+0141;y=;-0026;z=;-1144;FIFO_BUFF PLACE:;0132

798 02 00 01

x=;+0127;y=;-0035;z=;-1168;FIFO_BUFF PLACE:;0133

804 02 00 01

x=;+0124;y=;-0040;z=;-1137;FIFO_BUFF PLACE:;0134

810 02 00 01

x=;+0118;y=;-0029;z=;-1156;FIFO_BUFF PLACE:;0135

816 02 00 01

x=;+0120;y=;-0025;z=;-1136;FIFO_BUFF PLACE:;0136

822 02 00 01

x=;+0127;y=;-0028;z=;-1140;FIFO_BUFF PLACE:;0137

828 02 00 01

x=;+0185;y=;-0032;z=;-1154;FIFO_BUFF PLACE:;0138

834 02 00 01

x=;+0152;y=;-0029;z=;-1165;FIFO_BUFF PLACE:;0139

840 02 00 01

x=;+0125;y=;-0035;z=;-1151;FIFO_BUFF PLACE:;0140

846 02 00 01

x=;+0119;y=;-0042;z=;-1128;FIFO_BUFF PLACE:;0141

852 02 00 01

x=;+0134;y=;-0016;z=;-1129;FIFO_BUFF PLACE:;0142

858 02 00 01

x=;+0115;y=;-0021;z=;-1144;FIFO_BUFF PLACE:;0143

864 02 00 01

x=;+0137;y=;-0015;z=;-1138;FIFO_BUFF PLACE:;0144

870 02 00 01

x=;+0131;y=;-0025;z=;-1169;FIFO_BUFF PLACE:;0145

876 02 00 01

x=;+0143;y=;-0029;z=;-1157;FIFO_BUFF PLACE:;0146

882 02 00 01

x=;+0134;y=;-0036;z=;-1147;FIFO_BUFF PLACE:;0147

888 02 00 01

x=;+0129;y=;-0025;z=;-1137;FIFO_BUFF PLACE:;0148

894 02 00 01

x=;+0135;y=;-0020;z=;-1144;FIFO_BUFF PLACE:;0149

900 02 00 01

x=;+0131;y=;-0015;z=;-1137;FIFO_BUFF PLACE:;0150

906 02 00 01

x=;+0152;y=;-0036;z=;-1160;FIFO_BUFF PLACE:;0151

912 02 00 01

x=;+0135;y=;-0034;z=;-1154;FIFO_BUFF PLACE:;0152

918 02 00 01

x=;+0137;y=;-0032;z=;-1143;FIFO_BUFF PLACE:;0153

924 02 00 01

x=;+0134;y=;-0016;z=;-1141;FIFO_BUFF PLACE:;0154

930 02 00 01

x=;+0126;y=;-0036;z=;-1160;FIFO_BUFF PLACE:;0155

936 02 00 01

x=;+0135;y=;-0029;z=;-1145;FIFO_BUFF PLACE:;0156

942 02 00 01

x=;+0131;y=;-0047;z=;-1152;FIFO_BUFF PLACE:;0157

948 02 00 01

x=;+0112;y=;-0032;z=;-1152;FIFO_BUFF PLACE:;0158

954 02 00 01

x=;+0132;y=;-0029;z=;-1145;FIFO_BUFF PLACE:;0159

960 02 00 01

x=;+0124;y=;-0013;z=;-1144;FIFO_BUFF PLACE:;0160

966 02 00 01

x=;+0160;y=;-0026;z=;-1154;FIFO_BUFF PLACE:;0161

972 02 00 01

x=;+0152;y=;-0034;z=;-1158;FIFO_BUFF PLACE:;0162

978 02 00 01

x=;+0137;y=;-0031;z=;-1159;FIFO_BUFF PLACE:;0163

984 02 00 01

x=;+0152;y=;-0036;z=;-1145;FIFO_BUFF PLACE:;0164

990 02 00 01

x=;+0132;y=;-0036;z=;-1128;FIFO_BUFF PLACE:;0165

996 02 00 01

x=;+0135;y=;-0010;z=;-1136;FIFO_BUFF PLACE:;0166

1002 02 00 01

x=;+0103;y=;-0025;z=;-1137;FIFO_BUFF PLACE:;0167

1008 02 00 01

x=;+0136;y=;-0026;z=;-1137;FIFO_BUFF PLACE:;0168

1014 02 00 01

x=;+0135;y=;-0026;z=;-1154;FIFO_BUFF PLACE:;0169

_____________________________________________________________________________

Reading Status Now
_____________________________________________________________________________

X/Y/Z= -0.03/-1.14/0.13 Temp:73.41 Pin 13:0 STAT:6 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:512 loop:0 millis():1708


1
0
JUST_STILL is true.
loop iteration= 1

X/Y/Z= -0.04/-1.14/0.14 Temp:73.18 Pin 13:0 STAT:6 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:512 loop:1 millis():1727

Reading Status Now
_____________________________________________________________________________

X/Y/Z= -0.03/-1.16/0.12 Temp:73.06 Pin 13:0 STAT:6 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:512 loop:10000000 millis():8420


Reading Status Now
_____________________________________________________________________________

X/Y/Z= 0.14/-1.22/0.01 Temp:73.06 Pin 13:0 STAT:6 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:512 loop:20000000 millis():15113


0
1
JUST_MOTION is true.
loop iteration= 20000001
0
X/Y/Z= 0.20/-1.08/0.29 Temp:73.06 Pin 13:1 STAT:56 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:272 loop:20000001 millis():15133

Waiting for Inact bit to set

X/Y/Z= -0.07/-0.86/0.41 Temp:73.41 Pin 13:1 STAT:46 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:302 loop:20000001 millis():15151

Waiting for Inact bit to set

X/Y/Z= -0.05/-0.03/1.16 Temp:73.53 Pin 13:0 STAT:2E FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:513 loop:20000001 millis():16080

Read 512 (2-byte) samples, after reading that out into an array shift out any samples not part of a triplet measurement set off the front of the array (oldest)

X/Y/Z= -0.05/-0.02/1.19 Temp:73.53 Pin 13:0 STAT:2 FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:4 loop:20000001 millis():16109

Print buffer also looking at axis identificaiton bits
0 02 00 01

x=;+0116;y=;-0024;z=;-1124;FIFO_BUFF PLACE:;00

6 02 00 01

x=;+0137;y=;-0020;z=;-1128;FIFO_BUFF PLACE:;01

12 02 00 01

x=;+0127;y=;-0023;z=;-1146;FIFO_BUFF PLACE:;02

18 02 00 01

x=;+0134;y=;-0021;z=;-1159;FIFO_BUFF PLACE:;03

24 02 00 01

x=;+0137;y=;-0029;z=;-1149;FIFO_BUFF PLACE:;04

30 02 00 01

x=;+0126;y=;-0025;z=;-1149;FIFO_BUFF PLACE:;05

36 02 00 01

x=;+0143;y=;-0029;z=;-1156;FIFO_BUFF PLACE:;06

42 02 00 01

x=;+0132;y=;-0026;z=;-1165;FIFO_BUFF PLACE:;07

48 02 00 01

x=;+0120;y=;-0033;z=;-1152;FIFO_BUFF PLACE:;08

54 02 00 01

x=;+0112;y=;-0041;z=;-1145;FIFO_BUFF PLACE:;09

60 02 00 01

x=;+0105;y=;-0026;z=;-1141;FIFO_BUFF PLACE:;010

66 02 00 01

x=;+0115;y=;-0020;z=;-1140;FIFO_BUFF PLACE:;011

72 02 00 01

x=;+0135;y=;-0023;z=;-1136;FIFO_BUFF PLACE:;012

78 02 00 01

x=;+0158;y=;-0025;z=;-1124;FIFO_BUFF PLACE:;013

84 02 00 01

x=;+0148;y=;-0037;z=;-1141;FIFO_BUFF PLACE:;014

90 02 00 01

x=;+0143;y=;-0020;z=;-1151;FIFO_BUFF PLACE:;015

96 02 00 01

x=;+0148;y=;-0036;z=;-1136;FIFO_BUFF PLACE:;016

102 02 00 01

x=;+0161;y=;-0025;z=;-1152;FIFO_BUFF PLACE:;017

108 02 00 01

x=;+0139;y=;-0049;z=;-1133;FIFO_BUFF PLACE:;018

114 02 00 01

x=;+0108;y=;-0028;z=;-1160;FIFO_BUFF PLACE:;019

120 02 00 01

x=;+0084;y=;-0031;z=;-1151;FIFO_BUFF PLACE:;020

126 02 00 01

x=;+0084;y=;-0025;z=;-1160;FIFO_BUFF PLACE:;021

132 02 00 01

x=;+0096;y=;-0036;z=;-1159;FIFO_BUFF PLACE:;022

138 02 00 01

x=;+0112;y=;-0033;z=;-1160;FIFO_BUFF PLACE:;023

144 02 00 01

x=;+0135;y=;-0040;z=;-1164;FIFO_BUFF PLACE:;024

150 02 00 01

x=;+0131;y=;-0045;z=;-1165;FIFO_BUFF PLACE:;025

156 02 00 01

x=;+0108;y=;-0049;z=;-1145;FIFO_BUFF PLACE:;026

162 02 00 01

x=;+0120;y=;-0039;z=;-1138;FIFO_BUFF PLACE:;027

168 02 00 01

x=;+0139;y=;-0040;z=;-1120;FIFO_BUFF PLACE:;028

174 02 00 01

x=;+0124;y=;-0025;z=;-1136;FIFO_BUFF PLACE:;029

180 02 00 01

x=;+0118;y=;-0025;z=;-1137;FIFO_BUFF PLACE:;030

186 02 00 01

x=;+0143;y=;-0033;z=;-1149;FIFO_BUFF PLACE:;031

192 02 00 01

x=;+0124;y=;-0026;z=;-1167;FIFO_BUFF PLACE:;032

198 02 00 01

x=;+0131;y=;-0016;z=;-1162;FIFO_BUFF PLACE:;033

204 02 00 01

x=;+0140;y=;-0025;z=;-1157;FIFO_BUFF PLACE:;034

210 02 00 01

x=;+0140;y=;-0034;z=;-1156;FIFO_BUFF PLACE:;035

216 02 00 01

x=;+0123;y=;-0032;z=;-1156;FIFO_BUFF PLACE:;036

222 02 00 01

x=;+0099;y=;-0036;z=;-1161;FIFO_BUFF PLACE:;037

228 02 00 01

x=;+0099;y=;-0017;z=;-1160;FIFO_BUFF PLACE:;038

234 02 00 01

x=;+0095;y=;+0019;z=;-1165;FIFO_BUFF PLACE:;039

240 02 00 01

x=;+0073;y=;+0028;z=;-1181;FIFO_BUFF PLACE:;040

246 02 00 01

x=;+0102;y=;-0007;z=;-1181;FIFO_BUFF PLACE:;041

252 02 00 01

x=;+0079;y=;-0012;z=;-1184;FIFO_BUFF PLACE:;042

258 02 00 01

x=;+0088;y=;-0025;z=;-1177;FIFO_BUFF PLACE:;043

264 02 00 01

x=;+0076;y=;-0029;z=;-1177;FIFO_BUFF PLACE:;044

270 02 00 01

x=;+0103;y=;-0047;z=;-1208;FIFO_BUFF PLACE:;045

276 02 00 01

x=;+0120;y=;-0153;z=;-0986;FIFO_BUFF PLACE:;046

282 02 00 01

x=;+0039;y=;-0093;z=;-1361;FIFO_BUFF PLACE:;047

288 02 00 01

x=;+0060;y=;-0012;z=;-1016;FIFO_BUFF PLACE:;048

294 02 00 01

x=;+0105;y=;-0018;z=;-1308;FIFO_BUFF PLACE:;049

300 02 00 01

x=;+0054;y=;-0028;z=;-1049;FIFO_BUFF PLACE:;050

306 02 00 01

x=;+0159;y=;-0001;z=;-1272;FIFO_BUFF PLACE:;051

312 02 00 01

x=;+0073;y=;-0045;z=;-1098;FIFO_BUFF PLACE:;052

318 02 00 01

x=;+0108;y=;-0018;z=;-1250;FIFO_BUFF PLACE:;053

324 02 00 01

x=;+0102;y=;-0036;z=;-1130;FIFO_BUFF PLACE:;054

330 02 00 01

x=;+0071;y=;-0039;z=;-1192;FIFO_BUFF PLACE:;055

336 02 00 01

x=;+0124;y=;-0024;z=;-1137;FIFO_BUFF PLACE:;056

342 02 00 01

x=;+0078;y=;-0026;z=;-1178;FIFO_BUFF PLACE:;057

348 02 00 01

x=;+0088;y=;-0026;z=;-1140;FIFO_BUFF PLACE:;058

354 02 00 01

x=;+0140;y=;-0040;z=;-1185;FIFO_BUFF PLACE:;059

360 02 00 01

x=;+0126;y=;-0025;z=;-1145;FIFO_BUFF PLACE:;060

366 02 00 01

x=;+0160;y=;-0024;z=;-1160;FIFO_BUFF PLACE:;061

372 02 00 01

x=;+0147;y=;-0032;z=;-1156;FIFO_BUFF PLACE:;062

378 02 00 01

x=;+0176;y=;-0034;z=;-1161;FIFO_BUFF PLACE:;063

384 02 00 01

x=;+0159;y=;-0039;z=;-1177;FIFO_BUFF PLACE:;064

390 02 00 01

x=;+0147;y=;-0009;z=;-1232;FIFO_BUFF PLACE:;065

396 02 00 01

x=;+0126;y=;+0059;z=;-1118;FIFO_BUFF PLACE:;066

402 02 00 01

x=;+0080;y=;+0088;z=;-1133;FIFO_BUFF PLACE:;067

408 02 00 01

x=;+0119;y=;+0028;z=;-1184;FIFO_BUFF PLACE:;068

414 02 00 01

x=;+0135;y=;-0033;z=;-1249;FIFO_BUFF PLACE:;069

420 02 00 01

x=;+0083;y=;-0057;z=;-1216;FIFO_BUFF PLACE:;070

426 02 00 01

x=;+0048;y=;-0050;z=;-1210;FIFO_BUFF PLACE:;071

432 02 00 01

x=;+0057;y=;-0052;z=;-1220;FIFO_BUFF PLACE:;072

438 02 00 01

x=;+0057;y=;-0055;z=;-1224;FIFO_BUFF PLACE:;073

444 02 00 01

x=;+0024;y=;-0004;z=;-1175;FIFO_BUFF PLACE:;074

450 02 00 01

x=;-0004;y=;+0025;z=;-1213;FIFO_BUFF PLACE:;075

456 02 00 01

x=;-0017;y=;+0031;z=;-1236;FIFO_BUFF PLACE:;076

462 02 00 01

x=;-0005;y=;+0024;z=;-1257;FIFO_BUFF PLACE:;077

468 02 00 01

x=;-0017;y=;+0039;z=;-1265;FIFO_BUFF PLACE:;078

474 02 00 01

x=;+0007;y=;+0067;z=;-1264;FIFO_BUFF PLACE:;079

480 02 00 01

x=;-0001;y=;+0103;z=;-1245;FIFO_BUFF PLACE:;080

486 02 00 01

x=;+0009;y=;+0113;z=;-1229;FIFO_BUFF PLACE:;081

492 02 00 01

x=;-0025;y=;+0145;z=;-1215;FIFO_BUFF PLACE:;082

498 02 00 01

x=;+0012;y=;+0177;z=;-1232;FIFO_BUFF PLACE:;083

504 02 00 01

x=;+0028;y=;+0191;z=;-1224;FIFO_BUFF PLACE:;084

510 02 00 01

x=;+0049;y=;+0217;z=;-1208;FIFO_BUFF PLACE:;085

516 02 00 01

x=;+0071;y=;+0227;z=;-1201;FIFO_BUFF PLACE:;086

522 02 00 01

x=;+0143;y=;+0215;z=;-1160;FIFO_BUFF PLACE:;087

528 02 00 01

x=;+0191;y=;+0215;z=;-1136;FIFO_BUFF PLACE:;088

534 02 00 01

x=;+0248;y=;+0198;z=;-1081;FIFO_BUFF PLACE:;089

540 02 00 01

x=;+0287;y=;+0191;z=;-1088;FIFO_BUFF PLACE:;090

546 02 00 01

x=;+0277;y=;+0161;z=;-1021;FIFO_BUFF PLACE:;091

552 02 00 01

x=;+0248;y=;+0152;z=;-1017;FIFO_BUFF PLACE:;092

558 02 00 01

x=;+0283;y=;+0143;z=;-0945;FIFO_BUFF PLACE:;093

564 02 00 01

x=;+0392;y=;+0110;z=;-0968;FIFO_BUFF PLACE:;094

570 02 00 01

x=;+0420;y=;+0081;z=;-0903;FIFO_BUFF PLACE:;095

576 02 00 01

x=;+0441;y=;+0063;z=;-0776;FIFO_BUFF PLACE:;096

582 02 00 01

x=;+0502;y=;+0023;z=;-0817;FIFO_BUFF PLACE:;097

588 02 00 01

x=;+0452;y=;-0036;z=;-0669;FIFO_BUFF PLACE:;098

594 02 00 01

x=;+0412;y=;-0074;z=;-0861;FIFO_BUFF PLACE:;099

600 02 00 01

x=;+0414;y=;-0096;z=;-0555;FIFO_BUFF PLACE:;0100

606 02 00 01

x=;+0563;y=;-0148;z=;-0584;FIFO_BUFF PLACE:;0101

612 02 00 01

x=;+0515;y=;-0208;z=;-0554;FIFO_BUFF PLACE:;0102

618 02 00 01

x=;+0470;y=;-0265;z=;-0373;FIFO_BUFF PLACE:;0103

624 02 00 01

x=;+0448;y=;-0288;z=;-0367;FIFO_BUFF PLACE:;0104

630 02 00 01

x=;+0379;y=;-0284;z=;-0335;FIFO_BUFF PLACE:;0105

636 02 00 01

x=;+0425;y=;-0338;z=;-0241;FIFO_BUFF PLACE:;0106

642 02 00 01

x=;+0455;y=;-0353;z=;-0193;FIFO_BUFF PLACE:;0107

648 02 00 01

x=;+0527;y=;-0921;z=;-0071;FIFO_BUFF PLACE:;0108

654 02 00 01

x=;+0420;y=;-0242;z=;-0305;FIFO_BUFF PLACE:;0109

660 02 00 01

x=;+0252;y=;-0121;z=;-0344;FIFO_BUFF PLACE:;0110

666 02 00 01

x=;+0111;y=;-0564;z=;+0160;FIFO_BUFF PLACE:;0111

672 02 00 01

x=;+0200;y=;-0141;z=;-0390;FIFO_BUFF PLACE:;0112

678 02 00 01

x=;+0118;y=;-0052;z=;-0488;FIFO_BUFF PLACE:;0113

684 02 00 01

x=;+0326;y=;-0086;z=;-0225;FIFO_BUFF PLACE:;0114

690 02 00 01

x=;+0184;y=;-0114;z=;-0351;FIFO_BUFF PLACE:;0115

696 02 00 01

x=;+0023;y=;-0060;z=;-0324;FIFO_BUFF PLACE:;0116

702 02 00 01

x=;+0143;y=;-0104;z=;-0328;FIFO_BUFF PLACE:;0117

708 02 00 01

x=;+0248;y=;-0121;z=;-0273;FIFO_BUFF PLACE:;0118

714 02 00 01

x=;+0224;y=;-0074;z=;-0388;FIFO_BUFF PLACE:;0119

720 02 00 01

x=;+0223;y=;-0100;z=;-0215;FIFO_BUFF PLACE:;0120

726 02 00 01

x=;+0134;y=;-0104;z=;-0247;FIFO_BUFF PLACE:;0121

732 02 00 01

x=;+0084;y=;-0112;z=;-0253;FIFO_BUFF PLACE:;0122

738 02 00 01

x=;+0095;y=;-0103;z=;-0200;FIFO_BUFF PLACE:;0123

744 02 00 01

x=;+0190;y=;-0121;z=;-0289;FIFO_BUFF PLACE:;0124

750 02 00 01

x=;+0216;y=;-0076;z=;-0245;FIFO_BUFF PLACE:;0125

756 02 00 01

x=;+0255;y=;-0073;z=;-0144;FIFO_BUFF PLACE:;0126

762 02 00 01

x=;+0280;y=;-0097;z=;-0196;FIFO_BUFF PLACE:;0127

768 02 00 01

x=;+0228;y=;-0105;z=;-0124;FIFO_BUFF PLACE:;0128

774 02 00 01

x=;+0342;y=;-0409;z=;-0162;FIFO_BUFF PLACE:;0129

780 02 00 01

x=;+0422;y=;+0184;z=;+2047;FIFO_BUFF PLACE:;0130

786 02 00 01

x=;+2047;y=;+0368;z=;+0400;FIFO_BUFF PLACE:;0131

792 02 00 01

x=;+1854;y=;-2048;z=;+1008;FIFO_BUFF PLACE:;0132

798 02 00 01

x=;+2047;y=;-1068;z=;+0556;FIFO_BUFF PLACE:;0133

804 02 00 01

x=;+2047;y=;-0969;z=;+1670;FIFO_BUFF PLACE:;0134

810 02 00 01

x=;-1602;y=;-1137;z=;+1948;FIFO_BUFF PLACE:;0135

816 02 00 01

x=;+0369;y=;-0345;z=;-0032;FIFO_BUFF PLACE:;0136

822 02 00 01

x=;+1497;y=;-0144;z=;+0334;FIFO_BUFF PLACE:;0137

828 02 00 01

x=;+0833;y=;-0656;z=;+0352;FIFO_BUFF PLACE:;0138

834 02 00 01

x=;-0498;y=;-0148;z=;-0184;FIFO_BUFF PLACE:;0139

840 02 00 01

x=;-0688;y=;-0125;z=;-0034;FIFO_BUFF PLACE:;0140

846 02 00 01

x=;+0255;y=;+0439;z=;+0739;FIFO_BUFF PLACE:;0141

852 02 00 01

x=;+2047;y=;-1273;z=;+0968;FIFO_BUFF PLACE:;0142

858 02 00 01

x=;-2017;y=;-0084;z=;-0086;FIFO_BUFF PLACE:;0143

864 02 00 01

x=;-0199;y=;-0023;z=;+0135;FIFO_BUFF PLACE:;0144

870 02 00 01

x=;+1648;y=;+0086;z=;+0345;FIFO_BUFF PLACE:;0145

876 02 00 01

x=;+1129;y=;-0036;z=;+0099;FIFO_BUFF PLACE:;0146

882 02 00 01

x=;-0623;y=;-0121;z=;-0020;FIFO_BUFF PLACE:;0147

888 02 00 01

x=;-0628;y=;-0080;z=;-0018;FIFO_BUFF PLACE:;0148

894 02 00 01

x=;+0521;y=;-0082;z=;+0063;FIFO_BUFF PLACE:;0149

900 02 00 01

x=;-0241;y=;-1448;z=;+1031;FIFO_BUFF PLACE:;0150

906 02 00 01

x=;+2047;y=;-0921;z=;+0682;FIFO_BUFF PLACE:;0151

912 02 00 01

x=;+2047;y=;+0415;z=;+1833;FIFO_BUFF PLACE:;0152

918 02 00 01

x=;+2047;y=;-2048;z=;+0511;FIFO_BUFF PLACE:;0153

924 02 00 01

x=;+1380;y=;-1015;z=;+0595;FIFO_BUFF PLACE:;0154

930 02 00 01

x=;+1528;y=;+0004;z=;+0984;FIFO_BUFF PLACE:;0155

936 02 00 01

x=;+1796;y=;-1607;z=;+0746;FIFO_BUFF PLACE:;0156

942 02 00 01

x=;+1006;y=;-1972;z=;+1075;FIFO_BUFF PLACE:;0157

948 02 00 01

x=;+0676;y=;-0356;z=;+0234;FIFO_BUFF PLACE:;0158

954 02 00 01

x=;+0488;y=;-0136;z=;+0366;FIFO_BUFF PLACE:;0159

960 02 00 01

x=;+1087;y=;+0016;z=;+0411;FIFO_BUFF PLACE:;0160

966 02 00 01

x=;+0001;y=;-0047;z=;+0071;FIFO_BUFF PLACE:;0161

972 02 00 01

x=;+0443;y=;+0104;z=;+0416;FIFO_BUFF PLACE:;0162

978 02 00 01

x=;+1358;y=;+0185;z=;+0179;FIFO_BUFF PLACE:;0163

984 02 00 01

x=;+2047;y=;-0116;z=;+0223;FIFO_BUFF PLACE:;0164

990 02 00 01

x=;-0007;y=;+0120;z=;-0498;FIFO_BUFF PLACE:;0165

996 02 00 01

x=;+1536;y=;+0176;z=;+0568;FIFO_BUFF PLACE:;0166

1002 02 00 01

x=;+1471;y=;-0344;z=;+0939;FIFO_BUFF PLACE:;0167

1008 02 00 01

x=;+1748;y=;-0569;z=;+0699;FIFO_BUFF PLACE:;0168

1014 02 00 01

x=;+1831;y=;-2048;z=;+1734;FIFO_BUFF PLACE:;0169

_____________________________________________________________________________

1
0
JUST_STILL is true.
loop iteration= 20000002

X/Y/Z= -0.05/-0.02/1.21 Temp:73.18 Pin 13:0 STAT:E FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:513 loop:20000002 millis():17104

Reading Status Now
_____________________________________________________________________________

X/Y/Z= -0.03/-0.01/1.18 Temp:72.94 Pin 13:0 STAT:E FLTER_CTL:5 PWR_CTL:2 ACT_INACT_CTL:1F INTMAP2:40 FIFO_CTL:3 FIFO_SAMPLES:FF #FIFO:513 loop:30000000 millis():23797



typo
[edited by: iannecj at 10:51 AM (GMT -4) on 14 Oct 2020]
  • Here is code:

    #include <ADXL362.h>
    
    #define ADXL362_CS    5
    #define ADXL362_EINT  13
    
    volatile uint32_t i = 0;
    float x, y, z;
    int16_t  x16, y16, z16;
    float temp;
    unsigned char TEMP_L,TEMP_H;
    unsigned char ADXL_STATUS=0;
    unsigned char INTMAP2=0;
    unsigned char FILTER_CTL=0;
    unsigned char POWER_CTL=0;
    unsigned char ACT_INACT_CTL=0;
    unsigned char FIFO_CTL=0;
    unsigned char FIFO_SAMPLES=0;
    unsigned char FIFO_L=0;
    unsigned char FIFO_H=0;
    unsigned char FIFO_BUF[1024];
    unsigned char AWAKESTAT_LAST=0;
    unsigned char JUST_MOTION=0;
    unsigned char JUST_STILL=0;
    unsigned char pinStat=0;
    unsigned char watermark=3;
    uint16_t  FIFO_Total=0;
    
    void setup(void)
    {
        Serial.begin(115200);
        SPI.begin();
        pinMode(13, INPUT); // esp32 pin connected to adxl362 INT2
        pinMode(16, OUTPUT); //esp32 led
        pinMode(17, OUTPUT); //esp32 led
        digitalWrite(16,HIGH);//low lights led
        digitalWrite(17,HIGH);
          
        adiAccelerometer.begin(ADXL362_CS, &SPI, ADXL362_EINT); //These should be pins on esp32 for CS and where interuppt is wired...
        adiAccelerometer.setRegisterValue(0x00, ADXL362_REG_FILTER_CTL, 1); //zero this out before it sets below
         // sets data rate.
        adiAccelerometer.setOutputRate(ADXL362_ODR_400_HZ); //Set 400Hz data rate
        // Activity threshold 
        adiAccelerometer.setupActivityDetection(0x1F, 200, 2);
        //Configures inactivity detection. 
        adiAccelerometer.setupInactivityDetection(0x1F, 175, 250);
        // map awake bit to Int2 
        adiAccelerometer.setIntMap2(ADXL362_INTMAP2_AWAKE);
        adiAccelerometer.setRegisterValue(0x1F, ADXL362_REG_ACT_INACT_CTL, 1); //linked mode, referenced, act and inact enabled....means need to read status to clear
        //fifo setup...fifo status was default 0 before this command...now with this command it becomes 0x0B
        adiAccelerometer.fifoSetup(ADXL362_FIFO_TRIGGERED,0xFF,0);  //fifo triggered is enabled, middle number is waterMarkLvl - Specifies the number of samples to store in the FIFO., store temp ot nmo
        //adiAccelerometer.setRegisterValue(0x22, ADXL362_REG_POWER_CTL, 1); //ultra low noise mode, measurement mode
        // Waiting for the console to continue
        while (!Serial);
        Serial.println("STARTUP REGISTER READ JUST PRE MEASUREMENT MODE ");
        Serial.println("_____________________________________________________________________________ ");
        adxl362_info_status();
        Serial.println(" ");
        adiAccelerometer.setMeasurementMode();
        Serial.println("STARTUP REGISTER READ JUST POST MEASUREMENT MODE ");
        Serial.println("_____________________________________________________________________________ ");
        Serial.println(" ");
        adxl362_info_status();
        Serial.println(" ");
        
    } // end setup
    
    void loop(void)
    {    
       // poll esp32 pin 13 which is wired to adxl362 INT2(Awake status)
       pinStat=digitalRead(13);  
       //Light esp32 onboard light when awake
       if (pinStat) {
          digitalWrite(16,LOW);
          }
        else {
          digitalWrite(16,HIGH);  
          }  
    //look at awake pin state change...determine of just awoke (ACT) or just was still (INACT) based on AWAKE bit
    if (AWAKESTAT_LAST!=pinStat) {
       Serial.println(AWAKESTAT_LAST,DEC); //no state change
       Serial.println(pinStat,DEC); //no state change
       if (AWAKESTAT_LAST) {
                  JUST_MOTION=0;
                  JUST_STILL=1;
                   }
              else {
                    JUST_MOTION=1;
                    JUST_STILL=0;  
                   }   
       AWAKESTAT_LAST=pinStat;
       }
        else {
       }
    //we just went active, Awake just went one.  this section tries various timing and preconditions to read FIFO in order to catch motion trigger.
    if (JUST_MOTION) {
          Serial.println("JUST_MOTION is true.  ");
          printf("loop iteration= %d\n",i);
          Serial.println((ADXL_STATUS & ADXL362_STATUS_INACT),HEX);
          adxl362_info_status();
          Serial.println(" ");
          while (!(ADXL_STATUS & ADXL362_STATUS_INACT)) {
            adiAccelerometer.getRegisterValue(&ADXL_STATUS, ADXL362_REG_STATUS, 1);
            delay(10);
            Serial.println("Waiting for Inact bit to set ");
            Serial.println(" ");
            adxl362_info_status();
            Serial.println(" ");
      
           }
      Serial.println(" Read 512 (2-byte) samples, after reading that out into an array shift out any samples not part of a triplet measurement set off the front of the array (oldest)"); 
      //delay(500);
      adiAccelerometer.getFifoValue(FIFO_BUF,512);  // no shift in data read 512, AH set, fifosamples set to 00
      Serial.println(" ");
      adxl362_info_status();
      Serial.println(" ");
     }
    
    //we just went still (inact) and wake bit went to 0. clear out fifio buffer in esp32
    if (JUST_STILL) {
     Serial.println("JUST_STILL is true.  ");
     printf("loop iteration= %d\n",i);
     for (uint32_t k = 0; k < 1023; k++)   FIFO_BUF[k]=0; //clear all 
     Serial.println(" ");
     adxl362_info_status();
     Serial.println(" ");
    }
    
    //if loop was just motion, print local fifo buffer inclusing looking at axes idnetifer bits at beginning to make sure we have comple 3 axis sample set and not any misalignment of samples  
    if (JUST_MOTION ) {
        Serial.println("Print buffer also looking at axis identificaiton bits");
          for (uint32_t j = 0; j < 170 * 6; j+=6) {
                    //print a row of loop iteration number and the 3 samples for the following row axis identifiers
                    uint8_t xAddr = (FIFO_BUF[j+1] & 0xC0) >> 6;
                    uint8_t yAddr = (FIFO_BUF[j+3] & 0xC0) >> 6;
                    uint8_t zAddr = (FIFO_BUF[j+5] & 0xC0) >> 6;
                    printf("%u %02x %02x %02x\r\n", j, xAddr, yAddr, zAddr);
                    //now print row of values after stripping off axis identifers
                    int16_t x1 = convertFIFOdata(FIFO_BUF[j+1], FIFO_BUF[j]);
                    int16_t y1 = convertFIFOdata(FIFO_BUF[j+3], FIFO_BUF[j+2]);
                    int16_t z1 = convertFIFOdata(FIFO_BUF[j+5], FIFO_BUF[j+4]);
                    printf("x=;%+05d;y=;%+05d;z=;%+05d;FIFO_BUFF PLACE:;0%d\r\n",x1,y1,z1,j/6);
                }
         Serial.println("_____________________________________________________________________________ ");
         Serial.println(" ");
                   }
          if (!(i%10000000)) {
                  Serial.println(" Reading Status Now ");
                  Serial.println("_____________________________________________________________________________ ");
                  Serial.println(" ");
                  adxl362_info_status(); 
                  Serial.println(" ");
                  Serial.println(" ");
                  }  
    
    JUST_MOTION=0;
    JUST_STILL=0;  
    ++i;
    ;
    }
    ////End Main loop
    
    void adxl362_info() {
    
        adiAccelerometer.getGxyz(&x, &y, &z);
              adiAccelerometer.getXyz(&x16, &y16, &z16);
              temp = adiAccelerometer.readTemperature();
         //   adiAccelerometer.getRegisterValue(&ADXL_STATUS, ADXL362_REG_STATUS, 1);
              adiAccelerometer.getRegisterValue(&INTMAP2, ADXL362_REG_INTMAP2, 1);
              adiAccelerometer.getRegisterValue(&FILTER_CTL, ADXL362_REG_FILTER_CTL, 1);
              adiAccelerometer.getRegisterValue(&POWER_CTL, ADXL362_REG_POWER_CTL, 1);
              adiAccelerometer.getRegisterValue(&ACT_INACT_CTL, ADXL362_REG_ACT_INACT_CTL, 1);
              adiAccelerometer.getRegisterValue(&FIFO_CTL, ADXL362_REG_FIFO_CTL, 1);
              adiAccelerometer.getRegisterValue(&FIFO_SAMPLES, ADXL362_REG_FIFO_SAMPLES, 1);
              adiAccelerometer.getRegisterValue(&FIFO_H, ADXL362_REG_FIFO_H, 1);
              adiAccelerometer.getRegisterValue(&FIFO_L, ADXL362_REG_FIFO_L, 1);
              FIFO_Total=((FIFO_H & 0xFF) << 8) | FIFO_L;
              Serial.print(" X/Y/Z =  ");
              Serial.print(x);
              Serial.print(" / ");
              Serial.print(y);        
              Serial.print(" / ");
              Serial.print(z);     
              Serial.print(" Temp: ");
              Serial.print(temp);
              Serial.print(" Pin 13: ");
              Serial.print(digitalRead(13));
      //      Serial.print(" STAT: ");
      //      Serial.print(ADXL_STATUS,HEX);
              Serial.print(" FILTER_CTL: ");
              Serial.print(FILTER_CTL,HEX);
              Serial.print(" POWER_CTL: ");
              Serial.print(POWER_CTL,HEX);
              Serial.print(" ACT_INACT_CTL: ");
              Serial.print(ACT_INACT_CTL,HEX);
              Serial.print(" INTMAP2: ");
              Serial.print(INTMAP2,HEX);
              Serial.print(" FIFO_CTL: ");
              Serial.print(FIFO_CTL,HEX);
              Serial.print(" FIFO_SAMPLES: ");
              Serial.print(FIFO_SAMPLES,HEX);
              Serial.print(" # in FIFO: ");
              Serial.print(FIFO_Total,DEC);
              Serial.print(" loop: ");
              Serial.println(i,DEC);
    }
    
    void adxl362_info_status() {
    
            adiAccelerometer.getGxyz(&x, &y, &z);
            temp = adiAccelerometer.readTemperature();
            adiAccelerometer.getRegisterValue(&ADXL_STATUS, ADXL362_REG_STATUS, 1);
            adiAccelerometer.getRegisterValue(&INTMAP2, ADXL362_REG_INTMAP2, 1);
            adiAccelerometer.getRegisterValue(&FILTER_CTL, ADXL362_REG_FILTER_CTL, 1);
            adiAccelerometer.getRegisterValue(&POWER_CTL, ADXL362_REG_POWER_CTL, 1);
            adiAccelerometer.getRegisterValue(&ACT_INACT_CTL, ADXL362_REG_ACT_INACT_CTL, 1);
            adiAccelerometer.getRegisterValue(&FIFO_CTL, ADXL362_REG_FIFO_CTL, 1);
            adiAccelerometer.getRegisterValue(&FIFO_SAMPLES, ADXL362_REG_FIFO_SAMPLES, 1);
            adiAccelerometer.getRegisterValue(&FIFO_H, ADXL362_REG_FIFO_H, 1);
            adiAccelerometer.getRegisterValue(&FIFO_L, ADXL362_REG_FIFO_L, 1);
            FIFO_Total=((FIFO_H & 0xFF) << 8) | FIFO_L;
            Serial.print("X/Y/Z= ");
            Serial.print(x);
            Serial.print("/");
            Serial.print(y);        
            Serial.print("/");
            Serial.print(z);     
            Serial.print(" Temp:");
            Serial.print(temp);
            Serial.print(" Pin 13:");
            Serial.print(digitalRead(13));
            Serial.print(" STAT:");
            Serial.print(ADXL_STATUS,HEX);
            Serial.print(" FLTER_CTL:");
            Serial.print(FILTER_CTL,HEX);
            Serial.print(" PWR_CTL:");
            Serial.print(POWER_CTL,HEX);
            Serial.print(" ACT_INACT_CTL:");
            Serial.print(ACT_INACT_CTL,HEX);
            Serial.print(" INTMAP2:");
            Serial.print(INTMAP2,HEX);
            Serial.print(" FIFO_CTL:");
            Serial.print(FIFO_CTL,HEX);
            Serial.print(" FIFO_SAMPLES:");
            Serial.print(FIFO_SAMPLES,HEX);
            Serial.print(" #FIFO:");
            Serial.print(FIFO_Total,DEC);
            Serial.print(" loop:");
            Serial.print(i,DEC);
            Serial.print(" millis():");
            Serial.println(millis(),DEC);
    
    }
    
    ////////////////////////////////////////////////////////////////////////////////////
    // convert fifo sample to unsigned int
    ////////////////////////////////////////////////////////////////////////////////////
    int16_t convertFIFOdata(uint8_t hiByte, uint8_t loByte)
    {
        //mask off id bits, combine low byte
        int16_t q = ((hiByte & 0x3F) << 8) | loByte;
        // get sign bits, copy into B15, B14, combine
        q = ((q & 0x3000) << 2) | q;
        return(q);
    }
    
    
    
    /***************************************************************************//**
     * @brief Reads multiple bytes from the device's Ffifo buffer.
     *
     * @param pBuffer     - Stores the read bytes.
     * @param samples - Number of sanmples to read to read.
     *
     * @return None.
    *******************************************************************************/
    void ADXL362::getFifoValue(unsigned char* pBuffer, uint16_t samples)
    {
        unsigned char  buffer[1028];//Modifed by crhis this was 512 but thats not big enough since equal of 170 3 axis samples is 2 bytes.
        uint16_t index = 0;
    
        buffer[0] = ADXL362_WRITE_FIFO;
         for(index = 0; index < samples*2; index++)
         {
             buffer[index + 1] = pBuffer[index];
         }
        SPI_read(ADXL362_SLAVE_ID, buffer, samples*2);
        for(index = 0; index < samples*2; index++)
        {
            pBuffer[index] = buffer[index + 3];
        }
    }