frequencyTimer2 library crashes all codes

Hi there

Oh? no one has reported an issue with frequencyTimer2 yet ?

I haven't found why... it's the classic "it worked and it doesn't work anymore!"

I used fT2 with no worries to generate synchronized PWMs but probably an update (but which one after a total reinstall ?) and now my code crashes.
Also, the sample that comes with the library crashes just like. The library itself does not seem questioned, on gitHub it has not evolved for a long time.

If someone wants to check with a very simple code I suggest the following.
I am very very annoyed by this problem!! also many many thanks for any solution!

Code:
#include <FrequencyTimer2.h>

void setup() {
  Serial.begin(115200);
  delay(200);

  FrequencyTimer2::setPeriod(500)
  FrequencyTimer2::enable();
}

void setPWMs(void) {
  Serial.println("FT2_OK");
}

void loop() {
  FrequencyTimer2::setOnOverflow(setPWMs);

  Serial.println("loop");
  delay(1000);
}
 
FrequencyTimer2 is working fine for me on T3.5, with Arduino IDE 1.8.19 and TeensyDuino 1.58 beta2, Windows 7. I tested with both the Examples->Test sketch, and your program (needed semicolon after setPeriod(500)). Which Teensy, IDE, etc. are you using? What do you mean "it crashes"? What have you done to trouble-shoot?
 
Hello
kind of you to look at my problem...

=> Teensy 3.5, Arduino 1.8.19, teensyDuino 1.57. Nevertheless I tried 1.58 beta (no longer online??) and windows10.

Sorry, you are right "crash" was'nt a proper term. I meant that the code compiles, loads normally but then no response, not even to a "serial.print". Just like the small code attached. It works normally (but partially of course) as long as we don't uncomment the frequency timer.
Your answer tells me that my environment seems to be in question. the code also uses the libraries : ACAN, EEPROM, SPI, avr/io, avr/interrupt, but unrelated to the problem. Alas, I no longer know where to look!
anyway thanks to you
 
I've never used this library, and I don't know anything about the CMT (carrier modulator transmitter) that it uses, so I'm not sure where to look or what could be in conflict. CMT is also used by the IRRemote and Tlc5940 libraries. If you're not getting the expected interrupt, what I would try is

- comment out other initializers
- see if the FT2 interrupt works
- if yes, uncomment the others one by one
- see if there is one that stops FT2 from working correctly
 
Your answer tells me that my environment seems to be in question. the code also uses the libraries : ACAN, EEPROM, SPI, avr/io, avr/interrupt, but unrelated to the problem. Alas, I no longer know where to look!

What optimization level are you building with ?? Have you tried different optimization settings to see if that makes any difference ??

Mark J Culross
KD5RXT
 
Hi !
@ Joepasquariello
Uneasy to comment an initializer and keeping the sketch able to compile... the reason why I tested a sketch with ft2 as the only one. Such a sketch compiles but doesn't operate (in my case).

@ kd5rxt-mark
Optimizing the build is beyond my skills. Nevertheless I can ensure that the code respects the elementary rules relating to the structure as well as to the variables.
Moreover, its complexity is due to its networking but not to its size: "Sketch uses 34196 bytes (6%) / Global variables use 5472 bytes (2%)"
ideally I should handle the interrupt with direct port manipulation but I haven't found a way to do that with a teensy like I previously did with an avr2560.
As a guide, I enclose the interrupt function (every 150 microsecond). The goal is to constitute a binary chain activating some shift registers.

The most interesting thing today is that I have at least a solution ! But that's not an explanation what I'd prefer
Indeed, by transferring both .cpp/.h files in the sketch, it works anew...
The explanation will probably seem obvious to you! Not to me!!

(And here the interruption, for an improvement advice perhaps? Thanks in advance)
Code:
void setPWMregisters(void) {
  uint8_t chain = 0;
  step++;
  for (uint8_t section(16); section>0 ; section--) {
    chain = chain << 1;
    chain = (cran < PWMsection[section - 1]) + chain;
  }
  digitalWriteFast(LATCH_PWM, 0);       // latch = LOW
  SPI.transfer(chain);
  digitalWriteFast(LATCH_PWM, 1);       // latch = HIGH

  if (step == 128) /*=>*/ step = 0;     // => new PWM period
}
 
Hi !

ideally I should handle the interrupt with direct port manipulation but I haven't found a way to do that with a teensy like I previously did with an avr2560.

Code:
[/QUOTE]
No, ideally "direct port manipulation" shouldn't be needed.
An, indeed, digitalWrite[B][I]Fast[/I][/B] does exactly that, if pin is a constant.
 
Indeed, by transferring both .cpp/.h files in the sketch, it works anew...
The explanation will probably seem obvious to you! Not to me!!

That probably means that you have another copy of the library somewhere that Arduino is using instead of the one in your new installation of TD 1.58. If you were using FT2 for AVR, then you probably have a copy somewhere besides the one that got installed with TeensyDuino. If you go back to using the library rather than the CPP/H files, set your preferences for verbose output, and review the output, you can determine the location of FT2 that Arduino is linking, and possibly delete that. You might have copies of the other libraries, too.
 
argh I actually had a backup of my libraries! Joepasquariello you won the trip! and my thanks, above all.

Thanks also to Mcu32 for his comment.

Life is beautiful

Thanks again
 
Back
Top