SYS_delayMicrosecond.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002                            C   M O D U L E   F I L E
00003 
00004     Copyright (c) 2003 Neuros Audio LLC, All rights reserved.
00005 
00006 ******************************************************************************/
00007 
00016 
00017 /*-- HEADER FILE INCLUDES ---------------------------------------------------*/
00018 #include "sys_delay.h"
00019 #include "sys_clock.h"
00020 
00021 /*-- LOCAL DEFINITIONS -------------------------------------------------------*/
00022 
00023 /*-- STATIC DATA -------------------------------------------------------------*/
00024 
00025 /*-- GLOBAL DATA -------------------------------------------------------------*/
00026 
00027 /*-- FUNCTIONS ---------------------------------------------------------------*/
00028 #pragma CODE_SECTION(SYS_delayMicrosecond, ".sram0_resident")
00037 void SYS_delayMicrosecond(long lDuration)
00038 {
00039     long Delay; 
00040     
00041     UINT32 CPU_clock = SYS_getCPUClock();
00042 
00043     UINT16 CurrentPeriod, OldPeriod, TDDR;
00044     
00045     OldPeriod = TIM;        
00046         
00047     TDDR = TCR & 0x0f;      
00048 
00049     Delay = ((CPU_clock / 16384) / (TDDR + 1) * lDuration) / (1000000/16384);
00050     
00051     while (Delay > 0)
00052     {
00053         CurrentPeriod = TIM;
00054         
00055         if (OldPeriod < CurrentPeriod){
00056         
00057             Delay -= (OldPeriod + ( PRD - CurrentPeriod));
00058         }
00059         else {
00060         
00061             Delay -= (OldPeriod - CurrentPeriod);
00062         }
00063         
00064         OldPeriod = CurrentPeriod;
00065     }
00066 }
00067 
00068 /*****************************************************************************
00069                 Neuros Audio LLC. Confidential Proprietary
00070  *****************************************************************************/

Generated on Wed Jan 19 01:12:43 2005 for neuros-firmware by  doxygen 1.3.9.1