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

Thread: Suggestion for Interrupt (Audiolib) / NVIC_SET_PENDING

  1. #1
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679

    Suggestion for Interrupt (Audiolib) / NVIC_SET_PENDING

    Code:
    //Suggestion:
    #define NVIC_STIR		(*(volatile uint32_t *)0xE000EF00) //Software Trigger Interrupt Register
    //#define TRIGGER_INTERRUPT(x)    NVIC_SET_PENDING(x);
    #define TRIGGER_INTERRUPT(x)    NVIC_STIR=(x);
    Hi Paul, two little suggetions:
    a) during the search of a good "free" software interrupt for the mp3/aac audioobject, i noticed, that there unused ("reserved") interruptnumbers.
    You are using IRQ_SOFTWARE, and it is not free anymore for the user. You could use (for example) #55 instead, then IRQ_SOFTWARE stays available for the user.
    b) there is a register called "NVIC_STIR", Software Trigger Interrupt Register, which basically does the same as the Pending-Register - but you don't need the shifts. This needs less instructions.
    http://infocenter.arm.com/help/index...r01s01s01.html

    Regards, Frank
    Last edited by Frank B; 11-21-2014 at 08:30 PM.

  2. #2
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    961
    you could also do something like this:

    Code:
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
      NVIC_ENABLE_IRQ(IRQ_SOFTWARE);
      attachInterruptVector( IRQ_SOFTWARE, softISR );
      
    }
    
    
    void loop() {
      NVIC_SET_PENDING(IRQ_SOFTWARE);
      delay(1000);
    }
    
    
    void softISR() {
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
      Serial.println("ISR");
    }

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by duff View Post
    you could also do something like this:

    Code:
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
      NVIC_ENABLE_IRQ(IRQ_SOFTWARE);
      attachInterruptVector( IRQ_SOFTWARE, softISR );
      
    }
    
    
    void loop() {
      NVIC_SET_PENDING(IRQ_SOFTWARE);
      delay(1000);
    }
    
    
    void softISR() {
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
      Serial.println("ISR");
    }
    yes thatss the reason for my suggestion not to use IRQ_SOFTWARE. for audiolib.

  4. #4
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    961
    ah i see, you want to use it with audio library but couldn't you just use #55 instead also, but i agree that it would be an advatage to have that one open.

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    no,i could use #55, or any other. (i'm going to use #56)

    working example:
    Code:
    //a)
    #define RESERVED_INT  55 //or any other (reserved)
    //b) optional
    #define NVIC_STIR		(*(volatile uint32_t *)0xE000EF00)
    #define TRIGGER_INTERRUPT(x)    NVIC_STIR=(x);
    
    
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
      NVIC_ENABLE_IRQ(RESERVED_INT);
       _VectorsRam[RESERVED_INT  + 16] = softISR;
      
    }
    
    
    void loop() {
      //Trigger int this way 
      // NVIC_SET_PENDING(RESERVED_INT);
    
      //Or this way:
      TRIGGER_INTERRUPT(RESERVED_INT)
    
      delay(1000);
    }
    
    
    void softISR() {
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    }

Posting Permissions

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