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

nid help on LED blinking

i have problem with the led blinking. I using the exmaple program given by keil using uVision3. When i run the program, the LED on the development board didnt blink, it just stay on! wat should i do?

thanks!

Parents
  • It would be quite interesting the see the full code monkey rule set.

    delay( SCREEN_REFRESH_TIME );
    


    Swatting magic numbers and instead use constants is the next step up, when people have considered their use of symbol names and how to comment their code.

    Doing the swatting first would probably result in:

    enum {
        N = 17,  // N=18 seems a bit excessive.
        M = 12,  // Use 12.
        ...
    };
    
    wait(N); // need to wait
    

    or possibly introducing broken defines:

    #define M 12
    #define N M+5
    
    wait(N*1000); // us
    

Reply
  • It would be quite interesting the see the full code monkey rule set.

    delay( SCREEN_REFRESH_TIME );
    


    Swatting magic numbers and instead use constants is the next step up, when people have considered their use of symbol names and how to comment their code.

    Doing the swatting first would probably result in:

    enum {
        N = 17,  // N=18 seems a bit excessive.
        M = 12,  // Use 12.
        ...
    };
    
    wait(N); // need to wait
    

    or possibly introducing broken defines:

    #define M 12
    #define N M+5
    
    wait(N*1000); // us
    

Children
  • #define N M+5
    Always( always( always ) ) use parenthesis.

    #define N   (( ((M)) + ((5)) )) // (over) (use) (them) (!)
    


    Its in the book; on page( PARENTHESIS ) to be exact.

    It would be quite interesting the see the full code monkey rule set.

    Its basically standard stuff; a racy jacket, a steamy intro, the main characters are shallow, has a thin plot line, lots of typos, and has a dry, monotone-ish narration.

    In the end you are either a satisfied or you're left needing more.

    <excerpts from "Rules for Code Monkeys"...>

    Thou shalt not use Hungarian Notation.
    
    Thou shalt not use 'internet' code; unless an assignment is due,
    and the teacher can't tell the difference anyway.
    
    Thou shalt not kill (depending upon the project specifications)
    
    Thou shalt not use the closing bracket ']' symbol without first
    declaring allegiance to King Kong or saying several "Hail Fay Wray"s.
    
    Thou shalt not ramble-on-and-on in forums.
    
    etc.
    

    You know, the standard stuff.

    --Cpt. Vince Foster
    2nd Cannon Place
    Fort Marcy Park, VA

  • Yes, I know that you hate macros.

    I felt that I had to write that example just because the people in most need of good advice about symbol names and sw comments are quite likely to do produce such #define'd constructs.

    A #define'd expression without parentheses is definitely one of the mortal sins of programming - it doesn't matter if it is production code or just some test code.

    Another is to hide the #define'd symbol by not using capital letters.

    Or having a conditional #define that mucks up a dangling else. Or writing code that has a dangling else.

    A define that makes use of a parameter more than once is also quite high up on the no-no list. And code that does call a #define while using ++, -- or similar modifying accesses on one or more of the parameters.

    I haven't really decided what is the best way to get good developers.
    - Huge quantities of information.
    - Give people a bit of help into all kinds of traps and then have them learn why they got into the trap and how to avoid at least that speficic pot-hole in the future.

    In the end, hands-on experience with problems is quite efficient. People tend to remember a broken nose far longer than they remember the text in a school book. And they don't doubt the real pain that results from doing something the wrong way. The trick is to not produce permanent damage so they switch to another profession, and not to produce permanent monetary loss.

  • Now that is a real beaut.

    I just hope it was from a very bright student who wanted to be a bit cheeky with his teacher.

    I once saw some source code where the person didn't realize that decimal and hexadecimal is just different presentations of the same number, and that the C compiler supports hexadecimal constants.

    So the code contained:

    #define HEX_00 0
    ...
    #define HEX_A0 160
    #define HEX_A1 161
    ...
    #define HEX_FF 255
    


    Good to have in case he needed a hexadecimal number and forgot how to translate to decimal :)

    Or maybe he had seen one of the binary declarations that exists here and there, and not realized that a header file with:

    ...
    BIN_0110_1001 0x69
    BIN_0110_1010 0x6a
    ...
    


    exists just because binary numbers aren't part of the standard language, while the compiler has very good hexadecimal support directly in the language standard.

  • Thou shalt not kill (depending upon the project specifications)

    captain, what about the three rules of robotics... ;-)

  • They will not be introduced until the positronic brain has been released.

    By the way. Asimov later extended with a fourth rule about the good of the many, to avoid freezing and permanently destroyed positronic brains ;)

  • and, of course, he later introduced the "zero law" as well.