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
Sorry, I can't help with your problem, since I don't work with the C166 processor.
But one thing to think about is your assign of the double value in the interrupt handler.
Is the C166 processor capable of writing a double (or if it is just an alias for a float) atomically? If not, then the main loop may read broken values if the interrupt happens in the middle of a read, unless you synchronizes the accesses, possibly by _atomic_/_endatomic_.
Another thing: Are floating point operations supported in both the interupt handler and the main program at the same time?
Does it work if you declare z volatile?
volatile double z;
I see a couple of things.
Your interrupt priority is on level zero which will never allow it to vector so you need to move it off of zero.
Secondly I didn't see where you globally enabled interrupts?
Thirdly, not sure of the code sequence but if you are looking for a interrupt on the rising edge of P2.8 then here is your example slightly modified.
#include <xc167.h> double z; double Periode; void main (void) { CC1_M2 = 0x0001;// 001=>capture on posirtive Flanke CC1_T01CON = 0x0047; CC1_CC8IC = 0x0044; // Interrupt enable und, ILVL = 1 PSW_IEN = 1; // globally enable interrupts while(1) { z = Periode ; }//end of while }// end of main void Drehzahl_messung(void) interrupt(0x18) { Periode = 100; }
Hope this helps
View all questions in Keil forum