You are printing an error message even if sd.begin() succeeds, so maybe it is actually working
if (!sd.begin(SD_CONFIG))
Serial.println("Error mounting sdcard");
else
Serial.println("Error mounting sdcard"); // <---- this should be...
The analog mode is too complex for me to understand or debug visually. If your sketch works with inputMode IN1 or IN2, but not ANALOG, I would start by disabling the IntervalTimer so that frequency updates cannot occur during the display update.
Good advice here from Andy and Paul. I have a couple of recommendations on good programming practices that go back to the very early days. One is a paper titled Structured Design, by Stevens, Myers, and Constantine. This is a classic paper cited...
ADMUX, ADCSRA, etc. are AVR-specific registers. T4.x is not ARM, not AVR, so this code will definitely not work or even compile. You can use the standard Arduino API for analog inputs, i.e. analogRead(), etc., or you can look at the examples for...
If you search the forum for ST7789, you will find many threads and discussions of various libraries. Maybe also someone will tell you which is the "best", but you should start reading so that you know can figure out whether the screen you have is...
I think it's because elapsedMillis is a C++ object, and you're passing it to printf() as if it's an integer. I'm not much of C++ programmer, but I'm looking at the source in the T4 core, and it might work if you use the syntax t1() rather than...
I think you're unlikely to find support for a thousands separator in a printf() designed for embedded systems. I've been using printf() for a long time and had never even heard of that feature. According to my google search, it's required for...
Don't try to send 30000 float values in a single Serial.write(). Start with 10 to see if the handshaking works, then try to go up to 100 and then maybe you can even get to 1000. That would be 4000 bytes and it might work, but you also might have...
That looks good. If the update_firmware() succeeds, it won't return. If the buffer is in flash, it erases the buffer and calls REBOOT.
Regarding your assumptions:
The 64-sector reserve avoids FlasherX using flash that is used by T4.1 emulated...
Do you mind my asking the size of your application? If it's not too large, the time for FlasherX to erase/write can be pretty short, which mitigates the risk of power outage during that critical period. The application where I'm using FlasherX is...
Your original message says you want to "count the square waves", but your code does input capture and period measurement, so you probably want FreqMeasureMulti instead of FreqCountMany. The T4.1 pins available for FreqMeasureMulti are 0-9, 22-25...
This line is why it's not working when not connected to a PC:
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
If the USB port isn't connected to anything, the serial port will never be ready.
By default, with TeensyDuino installed, you will use the version of SdFat that is installed with TeensyDuino. It has some modifications from the standard SdFat to work with Teensy.
Paul wrote a sketch called FreqCountMany that uses QuadTimer to count rising edges on 10 input pins (6, 9, 10, 11, 12, 13, 14, 15, 18, 19). The counting is all done in hardware, so there is lots of processing time available for whatever else you...
In your loop(), you are calling getRpm() over and over and over with no delay between calls. On most of these calls, there will be no new data, so your getRpm() will return 0. The ONLY time your getRpm() function will return a non-zero value is...
Note in many of the subsystems, like, SPI, or I2C or SPI, there are often two different things.
The Arduino objects, like SPI, SPI1 and SPI2
And then there is the IMXRT object. From My own Excel document, we have SPI using pins 11-13 (and CS...
The FlexPWM timer used by FreqMeasureMulti requires very fast edges. Your signal looks like it has rather slow rise/fall times, and that will not work with FreqMeasureMulti. Can you add a schmitt trigger on your input?
When you set performance_status = true, you begin logging to SD, which you do from transducer_measure(), which is called from the ADC ISR. In transducer_measure, you write to the RingBuf, which you do via its print() method, then read from the...
See the examples for the FreqMeasureMulti library. With the standard CPU frequency of 600 MHz, the FlexPWM clock is 150 MHz, so you can get about 6 ns resolution. The begin() function has a parameter to define what you want to measure. The...
Something else to keep in mind is when you change F_CPU or call set_arm_clock(), you change both F_CPU_ACTUAL and F_BUS_ACTUAL, and the relationship between the two is not always the same. For example, if you call set_arm_clock(600), you get...
The link below will take you to a post where Paul discusses F_CPU_ACTUAL versus F_CPU. It says you should use F_CPU_ACTUAL, which is a uint32_t variable, not a constant. It doesn't say anything about...
Based on this description, I would say you should use FreqMeasureMulti, as opposed to Encoder or QuadEncoder. If you configure FreqMeasureMulti on both of the encoder output pins (A and B), you can record the time of each rising and falling edge...
Until now you haven't said what you are trying to accomplish. I mentioned that you can calculate speed because that is often what one does with a relative encoder. What are you doing with the encoder, and how fast is it going to turn (revs/sec or...
Could you add some state logic to your application to "shut down" before update? Maybe I misunderstand, but it sounds like you are doing build/update while your system is operating.
Use the QuadEncoder library on T4.x for this type of high-PPR encoder. No point in having hundreds or thousands of interrupts per second when they are easily avoided.
Use QuadEncoder, which does the quadrature counting entirely in hardware, with no interrupts. If you want to know the speed, use an IntervalTimer. In the IntervalTimer handler, read the encoder count value and subtract the value from the previous...
You don't specify which Teensy, but these days I assume 4.x, and therefore I would continue to use the RTC, for a couple of reasons. One is that the RTC built into T4.x has much higher backup current requirements than an external RTC. The second...
Just a note, I ran the SdFat library SdFormatter example sketch on my 32GB Sandisk Extreme, and I noticed that after the erase, it says "All data set to 0x00".
If you are using EEPROM, you must set the value of FLASH_RESERVE_HI in FlashTxx.h to 256KB (64 sectors) as shown below. This tells FlasherX that the buffer must be below EEPROM.
#elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
#define...
Yes, I think it is possible. Your programs have access to the program flash, which begins at address 0x6000'0000. If you look in cores\Teensy4\eeprom.c, you will find a function to erase a sector. If you erase the sector at the base address and...
Unlikely the flash would be going bad. It's good for something like 100,000 cycles. You should probably try just printing to the serial monitor instead of writing to your display, just to simplify things.