A problem with ISRs

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi, I am building a simple digital piano for my little sister. Nothing serious, just some bush buttons connected to intterupts, when a button is pressed the intterupt writes a value to a control register. the control register works as a select signal for a mux. the mux inputs are differnet clocks which serve as the piano tunes.

   

Now, the hardware is connected perfectly, every intterupt triggers perfectly, so here is the weird part:

   

When I press the first bush button, which is the tune A, everything works as it should, the intterupt triggers, the control register is written, then the return statement is excuted which brings the program back to main.

   

when I press the second bush button, the intterupt triggers, the control register is written, but the return statment is IGNORED. the program just keeps going to the next ISR where the its return statment is also ignored, and the next and the next until it creats an infinte loop outside of main.

   

I have uploded the project on two links if you care to shed some light on this problem.

   

http://www.mediafire.com/download/sp7z1hvm2ccu3eh/Simple_Piano_Using_Square_Waves.Bundle01.zip

   

https://drive.google.com/file/d/0BwvX4pp-M0KyNzlqY00yWUZzOGc/view?usp=sharing

0 Likes
10 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

What do you mean with "goes to the next ISR"? Is the same ISR called again?

   

How did you find about this? With the debugger? The reason might be that the interrupt trigger is level-based and not edge-based. Then it will be active as long as the button is pressed (and be executed when the interrupt-flag is cleared inside of the ISR)

0 Likes
Anonymous
Not applicable

 Yes I found that problem using the debugger, and what I mean by "goes to the next ISR" is that it finishes whatever I programmed the ISR to do and moves to perform the next ISR although it was not triggered. for example, when I press button 2 (tone C) the C ISR is performed. as soon as it is finished it moves directly to perform the D ISR without the intterupt being triggered, and then moves to the E ISR and so on until it returns to the C ISR and creates a loop.

   

all the intteurpts are rising edge based.

0 Likes
Anonymous
Not applicable

 No need, I found the problem, it was with the switch connections.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

That sounds interesting. How does a faulty switch wiring cause triggering one ISR after another?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

GPIO Interrupts covered here (explanation of port wide behaviour) -

   

 

   

    

   

          http://www.cypress.com/?rID=57571

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

@hli, no idea. I connected 5 switches with a pull down resistor, but only the first switch worked as it should. I removed the pull down connections and it worked like a charm. it still is a very strange problem.

   

@Dana, the answer might be in your document, I'll make sure to read it.

0 Likes
Anonymous
Not applicable

 In the document provieded by Dana, on page 16 it mentions 2 ports configured as a rising edge and falling edge interrupts.

   

3. Configure P6[0] as a resistive pull-down pin, or add 

   

an external pull-down.

   

4. Configure P6[1] as a resistive pull-up pin, or add an 

   

external pull-up.

   
        
   
    it says "or add", but what if we do both. because I configured my ports as resistive pull down and added an external pull down at the same time. could that be what caused the problem?   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you double up on PU's or PD's for sure you will burn more

   

power when switch closed.

   

 

   

Rare but if SW had high R when closed you might not meet noise margin,

   

eg. reflect a switch closure.

   

 

   

Just use internal, simpler.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Well, trust me Dana when I tell you that the lesson is well learned and won't be forgotten. Thank u.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Glad the forum was able to help.

   

 

   

Regards, Dana.

0 Likes