We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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.