Hi,
I have written a interuppt program for 1 second time delay. I am inserting the code with this mail, I am using pca with timer0 overflow as time base for pca. the timer 0 overflows at every 250us which is inturn given to PCA with 4000 times count. The code is working fine as single module , but when I attach this code with my on going project code the code is not working, I have not used any special registers of the chip AT89C51ED2, and in all EEPROM programs I have used EA=0 and EA=1 at begining and end of program. If there is any suggestion , plz help me to get out of this problem.
void timer_routine(void) interrupt 7 using 2 { EA=0; //disable all interrupt CL=0x5F; //loading 0xfo5f to pca counter CH=0xF0; CCF1=0; //clearing capture compare flag CF=0; //clearing pca counter overflow flag P2_6=~P2_6; //complementing the portpin EA=1; //enable all interrupt } void main() { IEN0=0xC0; //enable all interupt and pca interupt TMOD |=0x02; //set timer0 as timer TL0=0x00; //reload timer value as 0x1800 TH0=0x18; TF0=0; CMOD=0x05; //select timer 0 as pca clock and enable pca capture interupt CCAP1L=0x0A; //filling non zero values CCAP1H= 0x4F; CCAPM1=0x49; //setting ecom1 and mat1 and eccf1bits to use as software timer and enabling capture interupt CL=0x5F; // filling the pca timer CH=0xF0; CCAP1L=0xFF; //filling the capture ,compare modules CCAP1H= 0xFF; TR0=1; //run timer0 CR=1; //run pca timer P2_6=0; while(1); }
thats right, when you comment the code there IS a way to LOOK at ?
since i, fortunately, do not use Atmel devices, I can not help you with the particulars, however much I would like to help anyone that poresent fully commented and understandable code.
thus all I can give you is some general hints 1) many fail to realize that the PCA interrupt is a 'combined' interrupt and if you do not get all causes taken care of in the ISR. you eill ger right back in on the return 2) I am suspicious as to the enable PCA interrupt bit being IE0 bit 6, no other derivative I know of has it there, DO verify. 2) there is no need to disable and reenable interrupts at entry and exit from an ISR 3) have a look at The PCA cookbook www.intel.com/.../270609.htm
Erik
"I have written..."
Have you?
It looks very suspciously like the one that "Rajesh N" has written, here:
http://www.keil.com/forum/docs/thread8574.asp
even down to the spelling mistakes, and untidy tabulation of the comments.
Are you working together on this assignment?
No, i got the code from somewhere and made some changes to it,
yep, we are working together, how did you figure it out! Smart ah,