It's going to be a bit difficult to help since I don't understand your hardware, what you are counting on CounterA and CounterB, or what is glitchy, but I'll take a wild guess and mention that Teensy 4.0 is very fast,...
Hi Kurt. I tried this earlier today. With no change to SPI source, it's about the same as SPI.transfer16() with the set/restore of framesize. If you set the delay fields of TCR to 0, then you get about 2/3 of the...
Paul and the many contributors here do an amazing job of balancing simplicity for new users with access to all of the capability for the more advanced. Perhaps they will take your suggestion, but in the meantime, you...
Whoops. Compiler optimizations got me. The actual results are transfer16() = 465 cycles (775 ns) and specialtransfer16() = 404 cycles (673 ns), so the savings is 100 ns. The additional savings from reducing the CCR...
Yes, it is. The compiler is warning you that you have an IMPLICIT cast of const char* to char*. You can do that two ways. Either make everything const char*, or use an EXPLICIT cast to char* as in Kurt's second...
I may be able to help you. I've been working on a T3.5 project and maintaining compatibility with T4.1. Feel free to send me a PM with your email address.
Feel free to try it, but keep in mind a few things. You assignment statements may require more than one clock cycle, and they won't always get the same result due to the complexity of the processor (cache, etc.). Also,...
Maybe not. It really wouldn't make sense to turn the SPI library into a driver for a specific type of SPI device. The whole point is for SPI to hold what is common to all SPI, and to build libraries for various devices...
When you're looking for the value of a private data member of a class, it's always good to start with the constructor. In this case, the class is SPIClass, and the first argument gets assigned to port_addr. Then, on...
Have you tried it? I don't think it will even compile because port() is a private member function of the SPI class. It has no meaning when called without referencing the class instance.
port() is defined on line...
That's very clever. So, you're taking N measurements from 0-1 and calling that the "0-deg" data, then N measurements from 1-2 deg, etc.? And are you detecting 0 deg by the drop in output voltage of the position sensor?
The API for PWM includes analogWriteResolution, analogWriteFrequency, and analogWrite. I did a test using T4.1 pin 2, which uses a FlexPWM channel, and the following program, which sets up 100 kHz PWM. With a clock of...
I think the PWM is clocked at F_CPU/4, which would be 150 MHz, so you should be able to produce pulse widths down to about 6-7 ns at 10 kHz or 100 kHz. Give it a try.
If you google "Teensy 4 ADC Sample Rate", you...
This is all great info. So, the crank is spinning, and you do a series of measurements at 0 deg, then a series of measurements at 1 deg, etc? Is the output of the position sensor an analog value proportional to...
With that fix applied, the OP's program seems to work as intended. I'm not measuring current, but the LED does stop blinking for the period specified in the SnoozeTimer.
I tried the OP's program with both T4.0 and T4.1, and as soon as it gets loaded the Teensy crashes and does 9 blinks, which means...
So, I tried several of the Snooze Example programs, and they all have the same...
Any ISR or callback that you write yourself, or that you can modify, can include code to increment a counter. The processor itself does not count interrupts. What interrupt(s) do you want to count?
Cool and very impressive that you can put together something like this with mechanical, electrical, electronic, and software elements. I'm curious about the position sensor and how you use it to sample load position in...
I'm not clear on the meaning of "interrupt PENDING". IntervalTimer.begin() sets the interrupt enable flag (TIE) and clears the interrupt flag (TFLG). When a timer expires, TFLG is set, and if TIE is also set, an...
Paul, I think he is basing his design on my answer to his previous question about what happens on IntervalTimer::end(). Perhaps you can check my analysis in the message below.
...
I definitely agree with @mborgerson that synchronization and error checking are necessary for reliability. Here is an example using the SerialTransfer library, which handles packet creation, send, receive, and error...
In your example(), it's possible for an IntervalTimer to expire between the time interrupts have been disabled and end() is called. end() disables the interrupt and sets the callback function pointer for that particular...
This is not well-documented, but for T4.x, the argument to FreqCount.begin() is MICRO seconds, not MILLI seconds as for T3.x, so you are counting over just 1 ms instead of 1 sec as you wanted. If you update that...
Each ISR can keep a count of its executions. For each interrupt source, define a uint32_t variable and increment that variable within the ISR. Does this question relate to your other thread about too many interrupts...
Also, the QuadTimer peripheral used by the QuadEncoder library also has programmable input filters that may help with the OP's noise issue. I've never used the filters on QuadTimer, but I've had very good success in...
I don't know why the author has archived this repository, but he does have almost 1000 repositories, so maybe it was too much. Your question might relate more to QNEthernet than to the web server, so maybe its author...
You can get the library and its examples, etc. from the github link below. The T4.1 has only one CPU, but it also has many peripherals, including several types of timer that can count pulses or measure periods, and one...
You haven't told us any specific requirements, and I'm still not sure what you're trying to do except to produce a series of output edges in response to an input trigger. If you're going to use a periodic timer, you can...
I assumed you would set your periodic timer to trigger at 2x the frequency of your ouput, and then toggle a digital output on each interrupt so that you get a square wave at the desired frequency. Another way to do what...
Sounds like your sketch is fairly complex, so it's hard to say, but perhaps it has something to do with how you are using the other hardware serial functions after your calls to write(). For example, after your calls to...
There is more room for code because T4.1 has 8 MB of program FLASH, whereas T4.0 has 2 MB of program FLASH. The two pads on the bottom of T4.1 can be used for PSRAM and/or more FLASH, but neither of those increases the...
Okay, now I'm confused. You say in your OP that your problem goes away if you comment out the calls to rs485.write(), but now you say they take only 5 us. So, what's the problem?
You can move fonts to RAM2 at runtime. You can't locate anything into RAM at compile time. All of your code and data goes into FLASH, and it can be copied to RAM during boot or setup or anytime you want, but it still...
This is a wild guess because we can't see your code, don't know your platform, but are you using an RS485 library? If so, it may have blocking delays for RS485 bus control. If the RS485 is just a point-to-point link,...
I don't understand what you mean when you say "file memory was nearly eaten up again" on T4.1. Are you saying that your sketch is 2MB on T4.0, but somehow consumes 8MB on T4.1?
There is no way to load code/data...
At the bottom of the T4.x product page (below your quoted section) you will find links to the NXP reference manuals. It would be good to read up on the topic there, but here is a thread I found via google that...
The Audio library assumes the sample rate to be defined by macro AUDIO_SAMPLE_RATE_EXACT. Filter coefficients are a function of the ratio of critical frequency to sample frequency, so you could compute the ratio you...
You may also want to try replacing NativeEthernet with QNEthernet, which is based on lwip and is now better supported. Switching to QNEthernet has been helpful in quite a few instances.
If you get it working with...
Since you are using T4.1, if your frequencies are very high, you can access the hardware quadrature capability using the QuadEncoder library by @mjs513. This library lets you choose from a limited set of pins that...
I'm assuming this means you have interrupt on change of each A and B pin. For 6 encoders, that's a lot of interrupts if the frequencies are high. You could replace digitalRead() with digitalReadFast(), which should...
Interrupts can be set to different priorities, generally independent of pin numbers. Interrupts on multiples pins at once should not be a problem unless you cannot process them before another edge comes in on those same...
The Arduino reference may help.
https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/
https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
When you use analogWrite(), you are configuring the pin for PWM. Once you do that, if you want to switch back to digitalWrite(), you can probably do that if you call pinMode(13,OUTPUT). Don't think of analogWrite(13,0)...
One last comment, there is an event mechanism whereby your program can be "notified" that Serial.available() is true, but keep in mind this is done by polling behind the scenes, so it's probably more efficient for you...
Can you say more about what you're trying to do, and why you think you need to go to the lower levels and hook into the ISR? For all Serial comm, whether it's USB serial or UART (hardware) serial, the...
Installed 1.57b4 with Arduino 1.8.19 on Windows 7 Pro 64-bit. Built a few projects and all seems good.
Also installed under Arduino 2.x following update to 2.03. After restart of 2.0.3, clicked on option to update...
Recommend that you use QNEthernet rather than NativeEthernet, which is now obsolescent. Here is a link to the forum post with the latest release of QNEthernet. If the problem exists in QNEthernet and you post to this...
If you are using T4.0, the default space used by EEPROM is 15 sectors, plus there is one sector for the recovery program, so 16 would be enough. If you are using T4.1, EEPROM uses 63 sectors, plus 1 for the recovery...
Read the github readme info. The way that I use it in "production" is by reading the hex file into a Windows HMI program and sending the firmware to Teensy as larger blocks of binary data. On the Teensy side, I receive...
I can confirm that it works for all Teensy LC/3.x/4.x/MM. The sketch on github is a demo that lets you update firmware via UART for any Teensy or via SD for 3.5/3.6/4.1 with built-in SD card. For T3.2, the new firmware...
In FlashTxx.h there is a macro named FLASH_RESERVE, with default 0. If you are using EEPROM/LITTLEFS, you can set FLASH_RESERVE to however large a region you are using for this purpose, and FlasherX will search downward...
No, it is not necessary. T4.1 can work with buffer in RAM or in FLASH (default).
No, you don't have to do that. The program does it for you.
That's exactly what it does.
First, what is your platform, IDE, versions, etc? FlasherX works for all types of ihex records, pretty well tested.
If you want your buffer to be in RAM, just set the RAM buffer size to non-zero value, say...
A common issue is the USB cable is a power-only cable, as opposed to a cable that supports both power and commuication. If you have another cable, try it.