I need a millisecond and a second timebase on an Infineon XE160FU, so I concatenate GPT12E_T6 (timing milliseconds) and CC2_T8 (counting 1000 of those milliseconds). The T8 overflow should generate an interrupt.
The controller however never calls the ISR, and the Keil simulator reveals(?) that it is because the CC2_T8IC_IR flag never gets set, even though T8 overflows fine. In the simulator I can observe T8 overflowing and reloading with T8REL, but T8IC stays at 0x0070 instead of setting IR to become 0x00f0.
This confuses me because from the user manual I gather that IR gets set unconditionally whenever the timer overflows: Upon a timer overflow the corresponding timer interrupt request flag TxIR for the respective timer will be set. (UM chapter 17.1.2)
Interesting enough, if I let DAvE write the code, it is pretty much the same instructions, and correspondingly DAvE's code fails with the same symptom. Any idea?
unsigned long seconds = 0; void main() { unsigned int dummy; GPT12E_KSCCFG = 0x0083; /* Activate GPT12E and CAPCOM2 unstaggered */ dummy = GPT12E_KSCCFG; CC2_KSCCFG = 0x00b3; dummy = CC2_KSCCFG; CC2_IOC = 0x0004; GPT12E_T6IC_IE = 0; /* Configure GPT12E_T6 to expire every millisecond */ GPT12E_CAPREL = 4999; GPT12E_T6CON = 0x88c0; GPT12E_T6 = GPT12E_CAPREL; CC2_T8REL = (word) -1000; /* Let CC2_T8 count 1000 milliseconds */ CC2_T78CON = 0x4800; CC2_T8 = CC2_T8REL; CC2_T8IC = 0x0040 | (12 << 2); seconds = 0; while (1); } void once_per_second (void) interrupt 0x27 { _atomic_(0); seconds++; _endatomic_(); }