Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Higher ISR frequency than 1MHz on Teensy 3.6

  1. #1
    Junior Member
    Join Date
    Jan 2017
    Posts
    7

    Higher ISR frequency than 1MHz on Teensy 3.6

    Hi,

    Is there a simple possibility to get a higher interrupt frequency than 1MHz on Teensy 3.6 or Teensy 4.0? I tried the TeensyTimerTool lib (t1.beginPeriodic(ISR_x,1)), but there seems no possibility to set times under 1Ás.

    Thanks for help.
    Guy

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,704
    Quote Originally Posted by weigu View Post
    Hi,

    Is there a simple possibility to get a higher interrupt frequency than 1MHz on Teensy 3.6 or Teensy 4.0? I tried the TeensyTimerTool lib (t1.beginPeriodic(ISR_x,1)), but there seems no possibility to set times under 1Ás.

    Thanks for help.
    Guy
    The TimerTool timers accept floats as duration:

    Code:
      PeriodicTimer t1(TCK);   // or any other timer module
    
      t1.begin(ISR_x, 0.5);  // 500ns  
    
      // Or, if you prefer std::chrono literals: 
      t1.begin(ISR_x, 753ns);  // 753ns
      // or
      t1.begin(ISR_x, 0.0002ms) // 200ns  
     // or
      t1.begin(ISR_x, 2.5_MHz)
    Edit: The beginPeriodic interface is depreciated and will be removed in the future. Please use PeriodicTimer or OneShotTimer instead...

  3. #3
    Junior Member
    Join Date
    Jan 2017
    Posts
    7
    Hi luni,

    Thanks for your awesome library. I had tried floats with the MoreTimers example from your library. The code compiled, but I had no signal on my Osci. With PeridicTimer it works now. But the highest frequency I get is about 2.2MHz and not 10MHz as expected.

    Code:
    void pulse10ns() {
        digitalWriteFast(1, HIGH);
        delayNanoseconds(10);
        digitalWriteFast(1, LOW);
    }
    
    void setup() {
        pinMode(1,OUTPUT);
        t1.begin(pulse10ns,   0.1); // 10ns pulse every 100 ns
    }
    Thanks for your help

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,704
    10MHz is not really feasible. The IMXRT processor needs a lot of time to sync the peripheral bus and the 'main' bus in an interrupt. Using the TCK timers (purely software, no interrupts) you can get some 6MHz, with overclocking probably more. But at those high frequencies the processor is effectively blocked.

    If you only want to generate a 10Mhz signal as in your example you can use AnalogWrite which works in hardware without much loading of the processor. I don't remember the max frequency of AnalogWrite but I think 10MHz should be fine.

  5. #5
    Junior Member
    Join Date
    Jan 2017
    Posts
    7
    I need the interrupt for a DDS. What about hardware interrupts? Do I have to tweak the register or is there a possibility with the CMSIS interface?

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,704
    The TimerTool IS using hardware timer/interrupts and 'tweaks the registers' (only the TCK timers are software based). If you want to roll your own, this https://github.com/manitou48/teensy4 is a very good resource showing how to use the hardware timers. But, I would be very surprised if you can do anything reasonable while the processor runs interrupts at 10Mhz. There are some forum posts dealing with it: https://www.google.com/search?q=site...er+performance

  7. #7
    Quote Originally Posted by luni View Post
    The TimerTool IS I would be very surprised if you can do anything reasonable while the processor runs interrupts at 10Mhz.
    Agree. Does DDS stand for Direct Digital Synthesizer? You can try generating your waveforms without interrupts in a loop that uses delayNanoseconds() or reads the ARM cycle counter on each pass and takes action at the desired times.

  8. #8
    Junior Member
    Join Date
    Jan 2017
    Posts
    7
    DDS stands for Direct Digital Synthesis.
    http://weigu.lu/microcontroller/dds/index.html
    Thanks for your clarifications and the links. I'm not familiar with ARM processor and have to dig a little deeper

  9. #9
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,606
    Depending on what you output is, I'd think of DMA, perhaps... but to get the timing reliable is not that easy.

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,505
    Haven't used T_3.6 in some time - but overclocked to 256 with 128 MHz F_BUS edit will let it do the best it can - probably not enough?
    Code:
    C:\T_Drive\Arduino_1.8.16_155\hardware\teensy\avr\cores\teensy3\kinetis.h:
      764  #if (F_CPU == 256000000)
      765   #define F_PLL 256000000
      766:  #ifndef F_BUS
      767:  #define F_BUS 64000000
      768:  //#define F_BUS 128000000  // all the usual overclocking caveats apply...
    A T_4.1 @600 MHz can do over 5 MHz 'fast' interrupts but seems to falls short of 10 MHz before the it overwhelms the processor.
    IIRC the pin bus then runs at 150 MHz with 600 MHz T_4.1 - but has _isr overhead where the PORT of pins interrupt is multiplexed and has to be decoded.
    OC to 800 MHz not suggested (good cooling/heat sink and likely shorter life) - but would push the F_BUS to 200 MHz and give better response and more cycles to work with?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •