This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem in Interuppt Program

Hi,

I have written a interuppt program for 1 second time delay. I am inserting the code with this mail, I am using timer0 with 250ms which is inturn given to PCA with 4 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;
    CL=0x5F;
    CH=0xF0;
    CCF1=0;
    CF=0;
    P2_6=~P2_6;
    EA=1;
}

void main()
{


                IEN0=0xC0;  //C2
                TMOD |=0x02;
                TL0=0x00;
                TH0=0x18;
                TF0=0;
                CMOD=0x05;
                CCAP1L=0x0A;
                CCAP1H= 0x4F;
                CCAPM1=0x49;
                CL=0x5F;
                CH=0xF0;
                CCAP1L=0xFF;
                CCAP1H= 0xFF;
                TR0=1;
                CR=1;
                P2_6=0;



                while(1);

}

Parents
  • Your code would be much easier to read if you gave meaningful symbolic names to your constants (rather than just use magic numbers), and documented (in comments) what your code is supposed to be doing.

    Do this now - the exercise on its own might well lead you to your problem!

Reply
  • Your code would be much easier to read if you gave meaningful symbolic names to your constants (rather than just use magic numbers), and documented (in comments) what your code is supposed to be doing.

    Do this now - the exercise on its own might well lead you to your problem!

Children
  • one more case of "secrecy"

    I am using timer0 with 250ms
    sounds as iof you are using a very low oscillator ferquency, but you want to keep it secret what it is

    I have not used any special registers of the chip AT89C51ED2
    and the you go ahead and use the PCA which makes another poster (that need to read The PCA cookbook
    www.intel.com/.../270609.htm ) ask "what are these?"

    full info, commented code then maybe someone can help you.

    Keeping things secret (missing info scribbles (without comments nothing can be called 'code") are not conductive to getting an answer.

    Erik

  • "I have not used any special registers"

    Not forgetting, of course, that the 'S' in "SFR" stands for "Special"...!

    ;-)