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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/20/09 09:30
Read: times


 
#161628 - Too slow sampling
Responding to: ???'s previous message
Isn't the preview function supported in Australia?

By the way - bad code.

Your main loop is very aggresive with the last if statement.

It will do a LcdWriteString(" Hello World"); or a LcdClear(); on every iteration, i.e. as fast as it just able to. Why? Isn't it enough to do once for each flash++ ?

Another thing: modulo is expensive, so why do "flash % 4 == 0"? The compiler is probably smart enough to downgrade to an and operation, but you should consider using one explicitly in the code.

But more importantly. Your interrupt routine will tick a variable at every interrupt. But your main loop looks for an exact match. If the main loop calls a function that consumes more time than a single interrupt period, then you may miss that exact match, and the interrupt routine will have to continue to tick until the variable wraps around before you get another chance.

By the way - was that really the full source? What data type has the "intrptcnt" variable?

List of 11 messages in thread
TopicAuthorDate
Program Conflict            01/01/70 00:00      
   More info            01/01/70 00:00      
      Reply to Per Westermark            01/01/70 00:00      
         no code            01/01/70 00:00      
            Reply to no code            01/01/70 00:00      
               Too slow sampling            01/01/70 00:00      
                  Reply to Too Slow sampling            01/01/70 00:00      
                     Catch that magic marker            01/01/70 00:00      
                        Replay to Catch that magic marker            01/01/70 00:00      
   Edison            01/01/70 00:00      
   Try this...            01/01/70 00:00      

Back to Subject List