If you switch the standard library from the default newlib to newlib-nano your size difference shrinks down to a few 100 bytes. Here some info about the two versions of the standard library...
I recently stumbled over std::optional which comes in handy for such situations. Of course, changing an already published API is a no-go, but std::optional seems to be a nice tool for the toolbox...
#include <optional>
std::optional<unsigned>...
Instead of SMALLEST_CODE you could also try to add --specs=nano.specs which will switch to newlib-nano (same as SMALLEST_CODE does) but keeps the optimization level.
You are right of course. To be on the save side one should use
DMAMEM alignas(A) uint8_t buf[sizeof (A)]; // statically allocate memory for an object of type A
to allocate the buffer.
Here a quick test which shows that the compiler relys on initialization during startup.
class A
{
public:
int i = 42;
const int c = 17;
void print()
{
Serial.printf("i=%d &i=%p\n", i, &i);
Serial.printf("c=%d...
I have successfully worked on a proof of concept to upload ehex files with TeensySharp. However, I haven't integrated it into the library yet. Anyway, the purpose of TeensySharp is to allow users to integrate Teensy detection and firmware upload...
Actually isPressed() returns the debounced state of the button. So, replacing pressed() by isPressed() in @japreja s code should work.
Here an example showing the behaviour of isPressed()
#include "Bounce2.h"
Button b1;
void setup()
{...
Thanks, I'll fix that. However, CallbackHelper was just an experiment to understand how those things work. Please note that since the new TD1.59, the core contains teensy::Inplace_function which is a much better solution.
You can't.
For frequency measurements see here: https://www.pjrc.com/teensy/td_libs_FreqCount.htm
For pulse height you need to use analogRead, but that will be difficult if you have short pulses
For pulse width see here...
Paul gave you the link to the documentation of the library in #13 above. It contains all information how to use it. However, it does not contain a "simple list of commands".
I can give you examples if you tell us what you want to achieve with...
You didn't specify how precice you need that pulse. If you only need something roughly 10ns you can use the following code. It will generate a pulse of about 13ns every 50ms.
IntervalTimer timer;
void pulse()
{
digitalWriteFast(0,HIGH)...
Technically you'd put the objects in DMAMEM, not the class. Here an example: c1 lives in ITCM, c2 lives in DMAMEM and c3 in FLASHMEM
class myClass
{
public:
unsigned i = 42;
};
myClass c1;
DMAMEM myClass c2;
FLASHMEM const myClass c3;
void...
I just gave WebSerial a try. This is also very simple to use:
Here a simple test web page:
<!DOCTYPE html>
<html>
<head>
<title>Page Title2</title>
</head>
<body>
<h1>WebSerial Tester</h1>
<button type="button"...
@PaulS, Maybe I didn't understand this correctly, but I always thought WebUSB is a low level API where you directly communicate to endpoints / interfaces etc. Thus, wouldn't you need a corresponding driver on the Teensy side to make this work...
Actully accelstepper::run() is not very expensive and the T4.1 processor is quite fast. Here a simple test which moves 4 steppers with random parameters. tick() calls the run() functions of the steppers in a timer interrupt every 100µs. During...
In case WebHID is sufficient: I did try it some time ago, it worked nicely with minimal code: https://forum.pjrc.com/index.php?threads/making-webusb-work-with-the-teensy-what-is-pluggableusb.60782/post-247184.
I just tried it, it still compiles...
Yes, I'll never understand why the Arduino IDE doesn't have a simple "clean all". Anyway, the note is issued during compiling, not linking. So, in this case forcing a rebuild doesn't help.
I can reproduce that with @PaulStoffregen s code. I also saw that the warning/note is generated by the compiler, not the linker. So, opposed to what was written in the StackOverflow link it doesn't help doing a clean recompile. Anyway, you can...
The warning seems to be about linking code compiled with an older compiler to code compiled with a newer compiler. See here for details: https://stackoverflow.com/a/48149400/1842762.
Are you sure that you are doing a clean rebuild? Are you...
There still is a leftover from the old code in intervaltimer.h:
https://github.com/PaulStoffregen/cores/blob/c5e716375532ae0d8b912d7034707c0859b68801/teensy4/IntervalTimer.h#L73C2-L78C3
here the corresponding PR...
Registering an interrupt service routine (ISR) is usually done by storing its address in a table (often called the "vector table"). The IntervalTimer.begin() function does this for you. If an interrupt wtih number n occurs, the processor...
@cmarcus: Here you can experiment: https://godbolt.org/z/djMe46bj1
As mentioned above, signed integers generate much more code than an unsigned version
Couple of years ago I did a lot of experiments with high speed data transfer over usb serial. It turned out that on Win10 you can stably transfer some 10MByte/sec from a Teensy to a dotNet (C#) application.
However, there is a known bug in the...
Yes. However, a factory fresh Teensy has EEPROM values set to 255 and it copes with that.
The problem occurs on a Teensy which has been fine, and is fine when programmed with code from GCC5.3. So I'm not sceptical that correcting all the...
Some time ago there was a discussion in the forum about a very similar issue when an if clause checking the return value of new was not called correctly. Here the corresponding code
void setup()
{
while (!Serial);
void *p = new byte[1024 *...
Here a very simple method to check if something is eating up too much stack.
https://forum.pjrc.com/index.php?threads/teensy-4-1-cannot-make-use-of-free-memory-resulting-in-fw-crash.73203/#post-328880
Anyway, seems to be an interesting issue...
Usually you would use a *HCT since the input levels are better suited for a 3.3V controller output. But, the output rating of a HC/HCT chip is a bit borderline. Your driver is specd for typically 10mA (max 16mA) input current (probably a...
Thanks for the datasheet. Looks like you are right. Currently TeensyStep4 has the pulse polarity hardcoded, so I see 2 possibilities
You'll need a level shifter anyway since the driver requires >3.5V logic level. So, using an inverting shifter...
Here a minimal example:
void setup(){
}
void loop(){
time_t time = rtc_get(); // read the current time from the RTC
Serial.print(ctime(&time)); // convert time_t to readable string and print out
delay(1000);
}
which prints:
Sat...
What do you mean by "gather variables"? If you want to access class member variables from outside you can either make them public (not recommended) or write a 'getter' and/or a 'setter' function. The advantage of this approach is that you can...
I'm merrily pasting tat on here.... but hey ho.
I have got classes working. Moved some of my code out of my main ino file.
How do I retrieve variables I gather within a class and bring them back to the main ino code?
It probably runs on yield. e.g. after loop or while delay or other long running functions are spinning, or whenever you call yield in your code. But yes, this is not an interrupt.
Neither did I. So I did a quick test with USB-Serial which works nicely. Might come in handy sometime...
void serialEvent() // do your parsing here
{
char c = Serial.read();
// do something with the character
if(c == '1')
{...
BTW: for easy installation the library can be found on nuget. Documentation is a bit out of date but the examples in the gitHub repo should show how to use it.
https://www.nuget.org/packages/lunOptics.libTeensySharp/1.0.1?_src=template
If you are using windows you can use TeensySharp for such things. I did a quick proof of principle using this c# script:
using libTeensySharp;
var watcher = new TeensyWatcher(); // provides a list of connected Teensies
foreach (var teensy in...