20 likes | 189 Views
Incorrect. void hw_msDelay (unsigned int mS ) { unsigned int tWait , tStart ; tStart = ReadCoreTimer (); tWait = ( CORE_TICKS_per_MS * mS ) + tStart ; while (( ReadCoreTimer ()) < tWait ); LATBINV = LEDA ; }. void hw_msDelay (unsigned int mS ) // better names {
E N D
Incorrect void hw_msDelay(unsigned intmS) { unsigned inttWait, tStart; tStart=ReadCoreTimer(); tWait= (CORE_TICKS_per_MS * mS) + tStart; while((ReadCoreTimer()) < tWait); LATBINV = LEDA; } void hw_msDelay(unsigned intmS) // better names { unsigned inttStart, tStop, tWait; tStart=ReadCoreTimer(); tWait = (CORE_MS_TICK_RATE * mS); tStop = tStart + tWait; while(ReadCoreTimer() < tStop); LATBINV = LEDA; }
Correct Method void hw_msDelay(unsigned intmS) { unsigned inttStart, tWait; tStart=ReadCoreTimer(); tWait = (CORE_MS_TICK_RATE * mS); while((ReadCoreTimer() - tStart) < tWait); LATBINV = LEDA; // Toggle LEDA }