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

Keil APP NOTE 105

Refer to this app note, page 4. The routine to delay for a while. Rignt or wrong, this while will never end if 65535 - startcount is less than count?(ie..the number of ticks needed for the delay is more than the number the variable can increase before overflowing back to zero)

Parents
  • I think that what you're saying is only true if we were to ignore the actual data type of the variable being passed to timer0_delay. Because this variable is declared as unsigned and timer0_count returns type unsigned and start_count is type unsigned, this function will never go into an endless loop. What might happen, however, is that if you were to do something like cast an unsigned long to an unsigned int, its value would be changed and the function would not delay as long as you might have wanted.

Reply
  • I think that what you're saying is only true if we were to ignore the actual data type of the variable being passed to timer0_delay. Because this variable is declared as unsigned and timer0_count returns type unsigned and start_count is type unsigned, this function will never go into an endless loop. What might happen, however, is that if you were to do something like cast an unsigned long to an unsigned int, its value would be changed and the function would not delay as long as you might have wanted.

Children
No data