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
  • The comments are an improvement, but it's still a mass of magic numbers; eg,

    CCAPM1=0x49;  //setting ecom1 and mat1 and eccf1 bits
                  //to use as software timer and enabling capture interupt
    


    Are you sure that 0x49 is the right magic number for that particular set of bits? Wouldn't it be much clearer (and, hence, more maintainable) to define symbolic constants and write, say:

    CCAPM1 = ECOM1 + MAT1 + ECCF1; //to use as software timer and enabling capture interupt
    

Reply
  • The comments are an improvement, but it's still a mass of magic numbers; eg,

    CCAPM1=0x49;  //setting ecom1 and mat1 and eccf1 bits
                  //to use as software timer and enabling capture interupt
    


    Are you sure that 0x49 is the right magic number for that particular set of bits? Wouldn't it be much clearer (and, hence, more maintainable) to define symbolic constants and write, say:

    CCAPM1 = ECOM1 + MAT1 + ECCF1; //to use as software timer and enabling capture interupt
    

Children
  • "in all EEPROM programs I have used EA=0 and EA=1 at begining and end of program."

    What do you mean by that?
    Are you confusing "program" with "function"?

    "If there is any suggestion"

    If your timer code works alone, and then stops when integrated with something that's fiddling with the EA flag, I think there could be a clue there somewhere...

  • Somebody like who 's got an eye for detail could fix up the error..

  • you take a route very populat roday.

    "Somebody ... could fix up the error

    Why can that 'somebudy" not be you. Or is it you are very good at requesting "somebody" to do something (expecially do it for free), but see no reason to do anything yourself but request "somebody" to do it.

    Send me check for a consultant fee and I will gladly take the time to work through incomplete questions, uncommented code, vague descriptions etc trying to figure out what exactly is ment. For free I, find it reasonable to request. that all questions be answered in a clear, understandable way and code is formatted and commented.

    Erik

  • For free I, find it reasonable to request. that all questions be answered in a clear, understandable way and code is formatted and commented.

    You expect that, do you? Well, you got it here:

    http://www.keil.com/forum/docs/thread8551.asp

    yet even then you either couldn't be bothered to read or were incapable of understanding the responses.

  • yet even then you either couldn't be bothered to read or were incapable of understanding the responses.

    I read every response and, to the best of my ability, tried to understand them, if I did not I asked for clarification.

    I do believe that I did 'understand' and did reply "I save some confusion and add some (the added parantheses), albeit less, I do not think that is worth it".
    In another reply I staed "I do not see it feasible to look at anything else than the actual file you are to add the changes to"

    If, in any suggestion, the are no parantheses etc. added NOTHING BUT a 'preface' (e.g. TYPRA) to the lines, AND it does not involve looking at another file than the one you want to modify, then you are right that I "were incapable of understanding" and would appreciate it if you could explain (in that thread, please).

    Erik

  • so wat do you charge,

    assure that you WILL,