You have chosen a challenging problem, one that may not have a workable solution by direct manipulation of digital I/O. If you want to learn more about C++, perhaps work through examples in various libraries and online...
Your program seems okay, so my first guess would be that you have a measurement issue. Can you take a step back and tell us what you are trying to do, and why you are producing this 1 MHz square wave with a digital...
IntervalTimer.h now has just one version of begin() that uses "template <typename period_t" and handles both integer and float period arguments, but there are still two versions of update(). One takes unsigned int and...
I don't see anything about a unique ID in the datasheet for PSRAM (link below). The chip has an ID, but it's not a unique ID for each individual chip. There is a function named flexspi2_psram_id() in...
You can generate the signals in the callback, but you can't call analogRead() from the callback. I'm not sure what you're trying to do, so I can only make general suggestions. In your callback function, instead of...
You didn't show your code this time, but in your previous program, you have a 250-ns timer (4 MHz), and you are calling analogRead() from the callback. analogRead() takes much longer than 250 ns to execute, so that's...
It is very common for Teensy programs to contain code as shown below, which will loop forever in setup() if there is no USB serial connection.
Serial.begin(9600); // init USB serial
while (!Serial) {} //...
The program below shows three methods of doing analog read. You can get more than 10x faster by using the ADC library. You can also use the ADC library in asynchronous mode, either by starting a conversion, doing...
Can you avoid division by zero in your application? That's the simplest solution, but perhaps someone who knows more will provide more info and options here. I did some googling and found the application note below....
I wasn't sure about this. T3.6 has ARM M4 core, so that is where to look for info. It looks like DIVBYZERO exception is disabled by default, and can be enabled. I'm not sure what happens if you do a div-by-zero. Have...
There is overhead, but don't worry about that. You're not going to get very far doing serial data transfer without some structure. The code below is an example program from SerialTransfer. As you can see, you can...
You might want to look at the EasyTransfer or SerialTransfer library. These libraries provide functions to send/receive data via UART in simple packet structures. I recommend SerialTransfer over EasyTransfer, but a lot...
The latest FlasherX version has the correct 16MB value as shown below. This value is meant to represent entire flash, not a maximum buffer size.
#elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY_MICROMOD)
...
I did some testing, and I pretty quickly saw on the receive side an instance where a partial record was displayed, followed by a good record where the "tick" value increased by 40. I'm guessing this means that SD delay...
Using the code below to measure in ARM cycle counts, I get 20-21 cycles = 32.0 - 33.6 ns at 600 MHz.
With IDE 1.8.19 and TD 1.59b3, "invalid cast" compile error occurred for "constexpr", so it is commented out.
...
I don't think you can use SD, because that would imply that everything needed for file I/O by "flash_move" would be in RAM. It might work, but given the complexity of SdFat, it seems a bit unlikely. On the other hand, I...
I'll be able to do some testing with 2 x T4.1 tomorrow, but in the meantime:
in log_data(), there is no protection against overwriting data_array. If that happens, because dataChar is on the stack, you'll likely get...
I have a logic analyzer, but no scope. The hardware design is out of my scope and expertise, though I do try to learn and understand as much as possible. I must be learning something, because I understand most of your...
Thanks very much for this definitive statement. I tried it this morning and confirmed that if I call pinMode(6, INPUT_PULLUP) before calling FreqMeasureMulti's begin(6), that solves 99% of the noise issue. Throughout my...
Thanks. I have never delved into the pin configurations, but for this one case I have looked at the code in function pinMode() in digital.c and the configuration table in FreqMeasureMultiIMXRT.cpp/h. The table in...
Background is I'm working on a project where Teensy 4.1 is plugged into a socket on a custom PCB. Two low-res tachometer signals are input to two FlexPWM channels (pins 6,9) with an instance of FreqMeasureMulti for...
The string can be anywhere. The easiest way to make sure it's in your code is to #include "FlashTxx.h" and add the statement Serial.println(FLASH_ID). Without the println(), the compiler will optimize out the string....
You can ask questions here. Are you running the example program or have you added FlasherX to your own application? If it's your own application, are you using EEPROM or LittleFS? Those two features use upper Flash, so...
You could look at file biquad.h in the Audio library. It contains code to compute coefficients for 2nd-order filters with arguments including sample rate and critical frequency. Biquad filters can be cascaded to create...
Yes, agree. The OP said he needed variable sample rates and break frequencies, but didn't provide actual ranges, so I was guessing that the 8-bit coefficients in your fixed-point example wouldn't be enough. Who knows....
I'm guessing, but if everything else is the same, it must be related to the calling context. Are you calling the save function from within the context of handling the HTTP request? If so, can you simply set a flag from...
You can search the forum. I generally have more success with google. For this question, I googled "PJRC Teensy DMA Tutorial", and I got the link below
...
Just to explain why you need a larger RX buffer. In your loop() function, when record_data() is called, it will usually be pretty fast, but every once in a while, the SD card must do some "housekeeping", and when it...
Good points, Mark. The OP mentioned concern over quantization of coefficients, so I thought he wanted to use float, but either way it will be very fast.
You might be interested in the link below. FlasherX is code that you can include in your application to allow firmware updates over any connection (USB, UART, Ethernet, etc.). The concept is to buffer the new firmware...
Each high time and low time of both of your signals is 1 conversion, so the actual conversion frequency is about 55 kHz. The program below gets the same result. analogRead() is part of the standard Arduino API. If you...
If you use a first-order low-pass, there are no stability issues. You can use floating-point, and you can modify the coefficients to account for whatever break frequency and sample frequency you want. Would 300 ns per...
A simple exponential filter is 2 multiplies and 1 addition (output = A*input + (1-A)*output). If the code and data were all in fast RAM, wouldn't that be faster than a moving average with data in PSRAM, which means at...
Do you mean "fast to implement" (write the code) or "fast to execute"? I'm pretty sure a simple lag filter or even 2nd-order low-pass would be at least as fast to execute (because the memory would be in fast RAM) and...
Glad it's working and you are satisfied with using SD. Your calls to read/write via LittleFS contain only the address and size of your data structure. The details of the structure are not known to LittleFS, so...
Registers are defined in file "imxrt.h" in TeensyDuino folder "cores\Teensy4". The code below is from that file, and it shows the data structure for a single QuadTimer channel, and for a complete QuadTimer. You could...
I think @luni has provided some very useful info, but just to answer your question, when I said peripherals, I meant the internal peripherals (timers, SPI, I2C, etc.), not external peripherals. QuadTimer is one of the...
That's not too surprising. As far as I know, there is no synchronization capability with TeensyTimerTool or IntervalTimer, and you quickly run out of CPU when you try to generate the waveforms the way you are doing....
Yes, in PeriodicTimer::begin(), you specified a 1 us period, so you get one cycle of your waveform every 2 us (500 kHz). The period argument is a float, so you can specify 0.5 instead of 1, and that should give you 1...
Okay. I looked at the TCD1304DG data sheet and I see the variables in your code match the signal names. You may want to read the iMXRT manual's chapter on QuadTimer. Each timer has 4 channels, and I think you could use...
It would be helpful if you told us more about what you are doing, what is the ADC you are using, etc. 2000 ns is 2 us. You might be able to read a 12-bit bit value from an ADC in 2 us, but I don't think you could do it...
Perhaps you could try using IntervalTimer (https://www.pjrc.com/teensy/td_timing_IntervalTimer.html), which uses the processor's PIT (programmable interrupt timer) to generate interrupts at a fixed rate. You can...
I don't think the problem is using a header file. When I copied/pasted your filter class into a sketch and wrote a simple setup() function to exercise the filter, I was getting crashes. After some trial and error, I...
I copied your code into an INO (cpp) file, then de-constructed the class so the HP/LPFilter functions were local and defined them as inline. I could not get the same speed-up by defining them as inline within the class.
Thanks, Bob. I will give this a try and report back. Part of my confusion is the overuse of "Visual". Visual Studio, Visual Micro, Visual Teensy, VS Code, etc.
Hi Brian, I would like to try Visual Micro with Visual Studio, but I cannot make sense of the installation process. Do you have any notes on installation that you could share?
FlasherX can work with any method of transmitting the new firmware. If you can get the new firmware into a buffer in Flash or RAM, you can then do the update.
Please post a small, simple program that shows the issue (see Forum Rule). It's really not possible to say what might be wrong without seeing your code.
Well, unless I had a reason to think it was not possible for the MCP23S17 and AD9833s to share the same SPI, I think I would have tried to get that to work, since it seems an elegant design. I know that you did try, so...
Was it necessary to use the software SPI because the MCP library does not use SPI.begin/endTransaction? Otherwise, it seems like it should be okay to have 23S17 transactions before/after the AD9833 transactions.
...
Not sure about the 16 versus 10, but are you missing brackets after the statement with "if (SentOne == false)"? Perhaps that has an effect.
When you post code, please use the '#' button in the forum UI, else it's...
Thanks. Would you mind trying SD\Examples\SdFatUsage? Also, what version of TeensyDuino are you using? For a while now, SD has been just a wrapper on SdFat, and that's the example that helped me understand SdFat a...
I can't help troubleshoot, but just in case this isn't clear, the T4.1 built-in SD card is not connected via SPI. It is an SDIO connection. The value of BUILTIN_SDCARD is 255 (I think) which is really just a flag to...
The program below shows how to use sprintf() to write a float value to an array of char (C string). Below the program is the output on serial monitor. For the format string "%+8.1f", the total number of characters...
AndyA's advice is all very good. It's worth looking at the TeensySdioLogger example in the SdFat library. It does most (all?) of what he describes, with a couple of added bonuses. One is it shows how to use the...
Agreed. This is a great resource for anyone using GPS and wondering how to use PPS. If the PPS signal is configured for > 1 Hz, is there a way (in software?) to identify the "on-the-second" pulses?
One thing Paul pointed out, and I'm not sure you understood, is that '\0' is not a valid argument to the function scale(). The second argument should have type char*, but '\0' is type char with value 0. So, you are...
Try the eFlexPWM library by user epsilonrt at this link (https://github.com/epsilonrt/eFlexPwm). The "simple" example program produces 3 pairs of synchronized, complementary, center-aligned PWM, with optional deadtime....
My speculation...
The statements on the T3.x pages of PJRC's website don't provide much hope that Teensy LC and/or 3.x will be available in the future, and I haven't seen anything to indicate they have plans to...
Is your new board the Adafruit board you mentioned previously?
https://www.adafruit.com/product/4503?gclid=CjwKCAjw5remBhBiEiwAxL2M98SEF9qjYVVIIOoQN_Fs05SBtuLwOw4qCg0EfZd982OMlAEeWoS-PxoCAi8QAvD_BwE
Could be the 1-kHz systick interrupt? You can disable that if you want. I'm no expert on the data and instruction caching, but it's not like the simpler processors of the past.
When you post code, please use the...
Here is an "improved" example sketch for FreqCount that calls out the msec versus usec difference, and also shows the pin assignments
/* FreqCount - Example with serial output
*...
Someone else can explain better, but this sounds like it might be related to a problem related to initialization of static objects with the newer gcc toolchain used in 1.58. I might not have this right, but some object...
I don't think that's necessary, but I think it would be helpful for both teensy_size and the diagrams on the PJRC T4.0 and T4.1 pages to use the terms "heap" and "stack" instead of, or perhaps in addition to,...
The ADC library has quite a few additional features, such as simultaneous read from two channels on the two different converters, control of the conversion time, interrupt on conversion complete, etc.
That's cool. Thanks for posting.
Have you ever used the RingBuf included with the SdFat library? It supports writing of whole buffers, rather than byte-by-byte, and the SdFat example program shows how to use it...
You must add the FlasherX utility functions into your own application. Think of FlasherX as a set of functions that provide the following:
- create a buffer in flash or RAM to store the new firmware
- write the new...