11/*
22 October 11th, 2019
3-
4- Increase local serial, turn off except when syncing
5- Try better grade card
3+
4+ A stripped down sketch to test the reception of different speeds of serial
5+ and recording them to an SD card. Use with another board (RedBoard Artemis)
6+ and the ConstantSerialBlastTest.ino to send blocks of text. This sketch
7+ will output the # of bytes received so you can quickly see if all 30,000
8+ bytes made it over or if bytes were dropped.
69
710 460800bps = 2.17 * 10^-6 or 2.17us per bit
811 10 bits to the byte so 21.7us per byte
1114 16384 buffer size will allow for up to 355.532ms before bytes are dropped
1215 4096 buffer size will allow for up to 88.75ms before bytes are dropped
1316
14- How big is RX FIFO within HAL? 32 bytes
15- Is there a 'nearly full' interrupt for the RX FIFO?
16- We could check the RX FIFO empty bit in the ISR in a loop
17- We could increase the ISR priority level
18-
1917 ISR is currently 16us which supports 460800. We can burst mode to 8.5us.
18+
19+ With the most recent pull of the Apollo3 core from Github (ISR reduced, buffers
20+ increased to 4096), and a 512GB card, this sketch can correctly receive/store
21+ non-stop serial at 500000bps. Burst mode is not needed.
22+
23+ 691200bps is possible in burst mode
2024
2125*/
2226
2327// microSD Interface
2428// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
2529#include < SPI.h>
26- #include < SdFat.h> // We do not use the built-in SD.h file because it calls Serial.print
30+ #include < SdFat.h>
2731
2832const byte PIN_MICROSD_CHIP_SELECT = 10 ;
2933const byte PIN_MICROSD_POWER = 15 ; // x04
3034
31- SdFat sd;
32- SdFile serialDataFile; // Record all incoming serial to this file
35+ SdFs sd; // exFat Support
36+ FsFile serialDataFile; // Record all incoming serial to this file
37+
38+ // SdFat sd;
39+ // SdFile serialDataFile; //Record all incoming serial to this file
3340// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
3441
3542long overallStartTime; // Used to calc the actual update rate.
@@ -100,6 +107,16 @@ void setup() {
100107
101108 overallStartTime = millis ();
102109 // enableBurstMode(); //Go to 96MHz
110+
111+ Serial.println (" 1)Set baud to 115200" );
112+ Serial.println (" 2)Set baud to 230400" );
113+ Serial.println (" 3)Set baud to 460800" );
114+ Serial.println (" 4)Set baud to 500000" );
115+ Serial.println (" 5)Set baud to 691200" );
116+ Serial.println (" 6)Set baud to 921600" );
117+ Serial.println (" r)reset count" );
118+ Serial.println (" b)Enable Burst Mode" );
119+ Serial.println (" d)Disable Burst Mode" );
103120}
104121
105122void loop ()
@@ -115,7 +132,6 @@ void loop()
115132 serialDataFile.write (incomingBuffer, sizeof (incomingBuffer)); // Record the buffer to the card
116133 incomingBufferSpot = 0 ;
117134 }
118-
119135 charsReceived++;
120136 }
121137 lastSeriaLogSyncTime = millis ();
@@ -162,19 +178,34 @@ void loop()
162178 }
163179 else if (incoming == ' 4' )
164180 {
165- Serial.println (" Serial set to: 921600 " );
166- SerialLog.begin (921600 );
181+ Serial.println (" Serial set to: 500000 " );
182+ SerialLog.begin (500000 );
167183 }
168184 else if (incoming == ' 5' )
169185 {
170- Serial.println (" Serial set to: 500000" );
171- SerialLog.begin (500000 );
186+ Serial.println (" Serial set to: 691200" );
187+ SerialLog.begin (691200 );
188+ }
189+ else if (incoming == ' 6' )
190+ {
191+ Serial.println (" Serial set to: 921600" );
192+ SerialLog.begin (921600 );
172193 }
173194 else if (incoming == ' r' )
174195 {
175196 Serial.println (" Total count reset" );
176197 charsReceived = 0 ;
177198 }
199+ else if (incoming == ' e' )
200+ {
201+ Serial.println (" Burst mode enabled" );
202+ enableBurstMode (); // Go to 96MHz
203+ }
204+ else if (incoming == ' d' )
205+ {
206+ Serial.println (" Burst mode disabled" );
207+ disableBurstMode (); // Go to 48MHz
208+ }
178209 else if (incoming == ' \r ' || incoming == ' \n ' )
179210 {
180211 // Do nothing
0 commit comments