Hi everybody,
I'm working on P89V51RD2 at 11.0592Mhz from NXP with Keil uVision3, and I have got a problem on the PCA interrupts. The code I'm going to show you, is the simplified version of my code.
In fact, I use two module (0 & 1) of the PCA to (in this example) toggle an output. I explain, I have to set up the interrupt of the module 0, in my main.......
EA=0; /* INT desable */ TMOD=0x21; /*TIMER0 : 16 bit, TIMER1 : 8bit */ TL0+=0x66; /*Enable to have 1 milisecond as base time on PCA*/ TH0+=0xFC; CMOD=0x04; /* PCA Input = Timer 0 */ CCON=0x40; /* TCA timer on */ TCON=0x50; /*TIMER0 run, TIMER1 run*/ IP=0x00; /* 8-34 priorit‚ des IT : */ IE=0x42; /*IT TIMER0 and PCA */ EA=1; /* INT desable */ /*activate the module 0*/ CR=0; CCAP0L=CL+(T&0xFF); CCAP0H=CH+(T>>8); CCAPM0=0x49; CR=1; //T=1000 --> 1 second
....When the module 0 interrupt occurs, I set up the interrupt of the module 1.... When the one of module 1 occurs, I set up again the module 0..etc...
void pca(void) interrupt 6 { if(CCF0) { pin_test=~pin_test; CCF0=0; CCAPM0=0; CR=0; CCAP1L=CL+(T&0xFF); CCAP1H=CH+(T>>8); CCAPM1=0x49; CR=1; } if(CCF1) { pin_test=~pin_test; CCF1=0; CCAPM1=0; CR=0; CCAP0L=CL+(T&0xFF); CCAP0H=CH+(T>>8); CCAPM0=0x49; CR=1; } }
But that doesn't work correctly. I noticed different problems on my application, sometimes the output toggles but not at the right frequency, and sometimes it didn't toggle anymore. So, I have questions about that,
1 - Is my set-up wrong, or Am I forgot somethings? 2 - Is it possible to did that? (set-up the PCA interrupt module 1, in the module 0 interrupt).
Thanks in advance for your answers. Best regards,
Christophe HUCHET.