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

Thread: Interrupt issue

  1. #1
    Member
    Join Date
    Dec 2017
    Location
    Ohio
    Posts
    68

    Interrupt issue

    I am using a Teensy 4.1 with Win 10 in the Arduino IDE 1.8.19. I have a large project of 12,000 lines of C code that controls a 5 band HF, CW/SSB Software Define Transceiver. One of the encoders is placed in the Encoders.cpp file and has an ISR named EncoderFilter() which is couple via the attachInterrupt() call. I'm using the Rotary library that is distributed with the Arduino IDE to control the encoder. The interrupt code from the library's Example directory works flawlessly, using pins 14 and 15 for CW and CCW moment. I know it's heresy to put debug statements in an ISR, but I did and confirmed that the encoder indeed does sense the CW/CCW movement and correctly assigns the value into filterEncoderMove . This is the code:

    Code:
    void EncoderFilter()
    {
      char result;
    
      result = filterEncoder.process();   // Read the encoder
      if (result == 0) {                  // Nothing read
        filterEncoderMove = 0;
      } else {
        filterEncoderMove = (int) result; // 16 = CW, 32 = CCW
     }
    }
    There are 22 files in the project. The filterEncoderMove variable is a global volatile int data type. However, trying to examine filterEncoderMove in loop() consistently says the value is zero, even though I know it is properly set in the function. I tried for hours to figure this out.

    I have my problem fixed, but I don't know why it fixes it. To explain: because a Software Define Radio has a lot of stuff going on, I used the FASTRUN directive before loop(). I did NOT do that for the encoder function because the documentation says that functions, by default, are placed in the FASTRUN section of RAM1. I think I misunderstood that. As soon as I placed FASTRUN in front of the code above, loop() started processing the interrupt correctly. My question is: why didn't the interrupt work without FASTRUN? Does a FASTRUN loop() using interrupts need the ISR to be marked as FASTRUN? The project is Open Source so you can see the code if you wish in the Files section here.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,206
    Not seeling files at groups.io/g/SoftwareControlledHamRadio ... is membership required to view?

  3. #3
    Member
    Join Date
    Dec 2017
    Location
    Ohio
    Posts
    68
    Quote Originally Posted by defragster View Post
    Not seeling files at groups.io/g/SoftwareControlledHamRadio ... is membership required to view?
    Yes, it does, but you can join, read/download what you want, and then quit the group. Also, the way Groups work, in the Files section, click on Update twice to bring the latest posts to the top. The T41 project files were posted by me on June 3rd.

Posting Permissions

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