This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CC1_CC8IC interrupt

Hello
can someone tell me why my interrupt does not respond, with the debugger, I always get z = 0

double z;

main {
.
.
.
.
.
.

while(1)
 {
CC1_M2      =  0x0001;//  001=>capture on posirtive Flanke
CC1_T01CON  =  0x0047;
CC1_CC8IC   =  0x00C0; // Interrupt enable und
z = Periode ;
 }//end of while
 }// end of main


 void Drehzahl_messung(void) interrupt(0x18)
  {

Periode = 100;
  }


or what I have since forgotten
Thanks

Parents
  • What is generating your pulses?

    Have you verified that you don't have a bouncing signal, in which case the pulse may have ended before you enter your ISR. This will result in a zero length being sampled.

    Timer_alt and Timer_neu don't need volatile if they are only used inside the ISR. The volatile keyword is only needed when a variable may be asynchronously updated by other code or the hardware.

    The ISR may asynchronously update a variable with relation to the main loop. But the ISR does not see any asynchronous update (unless you support nested interrupts).

    If the input signal produces bouncing, then you should learn your ISR to not assign to the global Timer_Diff variable until after you have figured out if you sampled a bounce or a real signal, i.e. that the pulse had a certain minimum length.

    Another thing: Is there a reason for the use of a double? You can often use fixed-point arithmetic for handling this kind of data. But it depends a bit on what further evaluations you need to do with the value.

Reply
  • What is generating your pulses?

    Have you verified that you don't have a bouncing signal, in which case the pulse may have ended before you enter your ISR. This will result in a zero length being sampled.

    Timer_alt and Timer_neu don't need volatile if they are only used inside the ISR. The volatile keyword is only needed when a variable may be asynchronously updated by other code or the hardware.

    The ISR may asynchronously update a variable with relation to the main loop. But the ISR does not see any asynchronous update (unless you support nested interrupts).

    If the input signal produces bouncing, then you should learn your ISR to not assign to the global Timer_Diff variable until after you have figured out if you sampled a bounce or a real signal, i.e. that the pulse had a certain minimum length.

    Another thing: Is there a reason for the use of a double? You can often use fixed-point arithmetic for handling this kind of data. But it depends a bit on what further evaluations you need to do with the value.

Children
No data