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

configuring timer 2

i wanted to configure timer 2 of at89c51ed2
can any one give code to do so and and tell how to obtain a specific frequency.

Parents Reply Children
  • the freq was near high
    yes i include more header files; here they are.

    #include <stdio.h>
    #include <error.h>
    #include <file.h>
    #include "ramash.h"
    #include "file1.h"
    #include "file2.h"
    #include "file3.h"
    #include "file4.h"
    #include "file5.h"
    #include "file6.h"
    #include "file7.h"
    #include "file8.h"
    #include "file9.h"
    #include "file10.h"
    #include "file12.h"
    #include "counting.h"
    #include "include.h"
    #include "my_funcs.h"
    

  • Wait a minute. Exactly what did you comment?

    First of all, why do you add comments that duplicates the numbers from the instruction? Because you think people can't read the number in the assign?

    Don't you think that your comments should describe what the numbers mean instead? How did you computed your numbers? What does tha flag bits mean?

    Another thing - the numbers in the assignments are binary or hexadecimal. The numbers in your comments doesn't specify a number base. That should mean that they where base 10, something they obviously are not.

    And one more thing - how will you make sure that the numbers in the comment will match the value in the assign? Check the comment for the TMOD2 assign. Does it look ok?

    Something you have not answered: What is TH2? What happens when you write to it? Is there a rule that some assigns must be made before others?

    T2CON = 55h;      // set t2con to 55
    T2CAP1 = 12h;     // set t2cap1 to 12
    TMOD2 = 110101b;  // set tmod2 to 32
    TH2 = 1;          // set th2 to 1
    TL2 = 1;          // set tl1 to 1
    

    Never write comments unless they add some value. And when you do write comments - make sure they are correct!

  • How many of the include files in:

    #include <stdio.h>
    #include <error.h>
    #include <file.h>
    #include "ramash.h"
    #include "file1.h"
    #include "file2.h"
    #include "file3.h"
    #include "file4.h"
    #include "file5.h"
    #include "file6.h"
    #include "file7.h"
    #include "file8.h"
    #include "file9.h"
    #include "file10.h"
    #include "file12.h"
    #include "counting.h"
    #include "include.h"
    #include "my_funcs.h"
    

    do you think makes sense? How many can you describe the contents of, without opening it and check? Don't you think that files have names just to allow you to give them a meaningful name?