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

Thread: Compile error with noInterrupts() and interrupts()

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    2

    Compile error with noInterrupts() and interrupts()

    Hi, I'm trying to get the watchdog timer working on my teensy 3.6. After doing a little digging around I stumbled upon this post:
    https://forum.pjrc.com/threads/57131...981#post211981
    I decided to copy-paste the code to give it a try but when I tried compiling it I got the following errors:

    Code:
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/core_pins.h:34:0,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/wiring.h:39,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:45,
    
                     from C:\Users\MNI~1\AppData\Local\Temp\arduino_build_294619\pch\Arduino.h:6:
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:5675:56: error: expected ')' before '::' token
    
     #define __disable_irq() __asm__ __volatile__ ("CPSID i":::"memory");
    
                                                            ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/wiring.h:158:24: note: in expansion of macro '__disable_irq'
    
     #define noInterrupts() __disable_irq()
    
                            ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:38:1: note: in expansion of macro 'noInterrupts'
    
     noInterrupts();
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:2615:26: error: expected unqualified-id before 'volatile'
    
     #define WDOG_REFRESH  (*(volatile uint16_t *)0x4005200C) // Watchdog Refresh register
    
                              ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:39:1: note: in expansion of macro 'WDOG_REFRESH'
    
     WDOG_REFRESH = 0xA602;
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:2615:26: error: expected ')' before 'volatile'
    
     #define WDOG_REFRESH  (*(volatile uint16_t *)0x4005200C) // Watchdog Refresh register
    
                              ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:39:1: note: in expansion of macro 'WDOG_REFRESH'
    
     WDOG_REFRESH = 0xA602;
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:2615:26: error: expected ')' before 'volatile'
    
     #define WDOG_REFRESH  (*(volatile uint16_t *)0x4005200C) // Watchdog Refresh register
    
                              ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:39:1: note: in expansion of macro 'WDOG_REFRESH'
    
     WDOG_REFRESH = 0xA602;
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:2615:26: error: expected unqualified-id before 'volatile'
    
     #define WDOG_REFRESH  (*(volatile uint16_t *)0x4005200C) // Watchdog Refresh register
    
                              ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:40:1: note: in expansion of macro 'WDOG_REFRESH'
    
     WDOG_REFRESH = 0xB480;
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:2615:26: error: expected ')' before 'volatile'
    
     #define WDOG_REFRESH  (*(volatile uint16_t *)0x4005200C) // Watchdog Refresh register
    
                              ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:40:1: note: in expansion of macro 'WDOG_REFRESH'
    
     WDOG_REFRESH = 0xB480;
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:2615:26: error: expected ')' before 'volatile'
    
     #define WDOG_REFRESH  (*(volatile uint16_t *)0x4005200C) // Watchdog Refresh register
    
                              ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:40:1: note: in expansion of macro 'WDOG_REFRESH'
    
     WDOG_REFRESH = 0xB480;
    
     ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/kinetis.h:5676:55: error: expected ')' before '::' token
    
     #define __enable_irq() __asm__ __volatile__ ("CPSIE i":::"memory");
    
                                                           ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/wiring.h:157:22: note: in expansion of macro '__enable_irq'
    
     #define interrupts() __enable_irq()
    
                          ^
    
    E:\Projects\Plane\Flight Software\Various tests\WatchdogTest\WatchdogTest\WatchdogTest.ino:41:1: note: in expansion of macro 'interrupts'
    
     interrupts();
    
     ^
    
    WatchdogTest: In function 'void startup_early_hook()':
    WatchdogTest:63: warning: unused variable 'toval' 
         uint16_t toval = 1000;
    
                  ^
    
    Error compiling for board Teensy 3.6.
    Most of these errors originate in the kinetis.h file. I tried googling around to see if something was wrong with the syntax in the kinetis file but found nothing.
    Can anyone give any help with solving this issue?
    For the curious, I'm using Arduino 1.8.12 and Teensyduino 1.52 on a Windows 10 computer.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,749
    It compiles here without any errors on Linux.

    Click image for larger version. 

Name:	sc.png 
Views:	7 
Size:	80.6 KB 
ID:	20422

    This really should work on Windows too. My best guess is your Teensyduino install might be corrupted. Maybe Windows Defender or some other anti-virus interfered with the installer writing some of the files?

    My Windows test laptop currently needs some work (not booting...) so I can't easily test this on Windows right now. Maybe Defragster or something else with Windows can confirm?

  3. #3
    Junior Member
    Join Date
    Jun 2020
    Posts
    2
    I just compiled on a different windows computer and the code compiled fine, must be an issue with the install on my end then.

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,400
    Just used this the other day to work - compiling for T_4.0 on Win 10 w/IDE 1.8.12 and TS 1.52:
    Code:
        __disable_irq();
        mtCountL = mtCount;
        mtCount = 0;
        mtCountLB = mtCountB;
        mtCountB = 0;
        __enable_irq();
    Just changed to this and it also compiles:
    Code:
        noInterrupts();
        mtCountL = mtCount;
        mtCount = 0;
        mtCountLB = mtCountB;
        mtCountB = 0;
        interrupts();
    Just recompiled for T_3.6 and the second also works.


    Separate Issue but it was for the 500KHZ interrupt thread - the T_3.6 is WAY FASTER than the T_4.0. Will look for that thread and post results there.

    The T_3.6 can do two of these and have loop() cycles counts to spare!:
    Code:
    T:\tCode\Interrupts\IntTimerSample\IntTimerSample.ino Jun  2 2020 11:11:52
    mt#=1334453 with LoopCount=1866817	mtB#=1334558
    mt#=1333134 with LoopCount=1864782	mtB#=1333232
    Timer _isr()'s - the T_4.0 cannot run this:
    Code:
      MyTimer.begin(mt_isr, 0.75);
      MyTimerB.begin(mt_isrB, 0.75);
    T_4.0 can this:
    Code:
      MyTimer.begin(mt_isr, 0.75);
      MyTimerB.begin(mt_isrB, 2);
    T_4 (and T_4.1) is running this today - but less overhead for loop()'s - it looked like it failed the other day but can run:
    Code:
    T:\tCode\Interrupts\IntTimerSample\IntTimerSample.ino Jun  2 2020 11:20:21
    mt#=1143975 with LoopCount=349182	mtB#=1144058
    mt#=1142836 with LoopCount=348687	mtB#=1142915

    with slower loop() cycle count:
    Code:
    T:\tCode\Interrupts\IntTimerSample\IntTimerSample.ino Jun  2 2020 11:07:36
    mt#=1334663 with LoopCount=1000782	mtB#=500498
    mt#=1333335 with LoopCount=999635	mtB#=500001
    With those same two times the T_3.6 gives:
    Code:
    T:\tCode\Interrupts\IntTimerSample\IntTimerSample.ino Jun  2 2020 11:15:09
    mt#=1334623 with LoopCount=2291905	mtB#=500496
    mt#=1333308 with LoopCount=2289473	mtB#=500000
    Last edited by defragster; 06-02-2020 at 06:27 PM.

Posting Permissions

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