
Das Blinkenlights 17
* Notes: This function is specific to Arcom's Target188EB board.
*
* Returns: None defined.
*
**********************************************************************/
void
toggleLed(unsigned char ledMask)
{
asm {
mov dx, P2LTCH /* Load the address of the register. */
in al, dx /* Read the contents of the register. */
mov ah, ledMask /* Move the ledMask into a register. */
xor al, ah /* Toggle the requested bits. */
out dx, al /* Write the new register contents. */
};
} /* toggleLed() */
delay
We also need to implement a half-second (500 ms) delay between LED toggles.
This is done by busy-waiting within the delay routine shown below. This routine
accepts the length of the requested delay, in milliseconds, as its only parameter. It
then multiplies that number by the constant CYCLES_PER_MS to obtain the total
number of while-loop iterations required to delay for the requested time period.
/**********************************************************************
*
* Function: delay()
*
* Description: Busy-wait for the requested number of milliseconds.
*
* Notes: The number of decrement-and-test cycles per millisecond
* was determined through trial and error. This value is
* dependent upon the processor type and speed.
*
* Returns: None defined.
*
**********************************************************************/
void
delay(unsigned int nMilliseconds)
{
#define CYCLES_PER_MS ...