Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Per Westermark
06/09/12 06:04
Read: 726 times
Sweden


 
#187647 - So check without scope - adjust code until testable
Responding to: ???'s previous message
You didn't post full code.

But anyway - you have a function delay_ms().

You don't need a scope to make sure this function performs reasonably.

1000 calls to this function, with 10 as argument should be 10 thousand milliseconds - or 10 seconds.
100 calls to this function, with 100 as argument should also be 10 thousand milliseconds - or 10 seconds.

Have you verified that you can turn on a LED on a processor pin, and have the LED lit for 10 seconds before it is turned off?

By the way - busy-loop delays like that can often be totally removed since they don't actually do anything. They don't have any side effect, leaving the processor or the memory in any different state. So the compiler don't see a use for the loop.

Yet another thing - a busy-loop delay depends on what the generated code looks like. So it differs between different compiler manufacturers, or between different versions of the compiler from the same manufacturer or because of memory model or optimization setting or what registers etc happens to be available.

When you write low-level code, it is very good to have a digital oscilloscope. But lots of things can be tested without one, if you have a couple of LED or a multimeter. But it is up to you to sit down and think how code can be split up into smaller blocks, and how individual blocks can be tested.

If you have a state machine where multiple pins should toggle in some sequence, you can test that by introducing much longer delays between each pin change, so the action is slowed enough that you can see it with your eyes. Then you know the sequence is correct. And as I mentioned earlier - a fast delay can be checked by calling it many times, and verify that the delay gets properly scaled.

List of 20 messages in thread
TopicAuthorDate
help me with 93c46 and at89s52---MikroC      Mandeep Singh      06/03/12 16:29      
   What You Need to Do Yourself        Michael Karas      06/03/12 17:33      
      need help - 93c46 using AT89s52 - mikroc      Mandeep Singh      06/09/12 04:59      
         MikroC is unwise choice      David Prentice      06/09/12 09:34      
   help me with 93c46 and at89s52---MikroC      Mandeep Singh      06/09/12 05:01      
      So check without scope - adjust code until testable      Per Westermark      06/09/12 06:04      
         you have now 3 times asked help with 93c46/at89s52--MikroC      Erik Malund      06/11/12 07:36      
            93c46/at89s52--MikroC      Mandeep Singh      06/11/12 10:36      
               my suggestion      Erik Malund      06/11/12 11:27      
               You have already been given suggestions      Per Westermark      06/11/12 11:55      
                  help me with 93c46 and at89s52---MikroC      Mandeep Singh      06/12/12 08:33      
                     Use a proper Compiler      David Prentice      06/12/12 08:42      
                        I wanna, I wanna, I wanna,      Erik Malund      06/12/12 09:15      
                     Time to actually prove your logic and your delays      Per Westermark      06/12/12 09:21      
                        ----thanks all for helping out      Mandeep Singh      06/12/12 10:54      
                           do you REALLY expect ....      Erik Malund      06/12/12 11:29      
                     If you can't get MikroC to work ...      Richard Erlacher      06/12/12 15:25      
                        switching to keil      Mandeep Singh      06/13/12 14:32      
                           Example code on this website      David Prentice      06/13/12 15:05      
                           why, oh why      Erik Malund      06/13/12 18:06      

Back to Subject List