/*
 * wait.c
 * The function in this file makes a delay of 1 ms
 
 * $Author: b06900 $
 * $Date: 2008/03/05 22:49:11 $
 * $Name:  $
 */
 
#include <hidef.h>


#define BUS_SPEED 4200000 /* Hz */

#define CONST (BUS_SPEED / 1000 /*ms*/ / 8 /* loop cycles*/ )


void Wait1ms(void){
   asm {  
     PSHX
     PSHH
     LDHX #CONST
     loop:
     AIX #-1  ;2 cycles
     CPHX #0  ;3 cycles
     BNE loop ;3 cycles              
     PULH
     PULX
   }     
}