Esempio n. 1
0
void displayRunTestResults()
{
#if defined(TIME_DAC_ISR)
    UINT16 maxSamplesUsed = TEST_SAMPLES_NUM/5;
    long double avgInterTicks = 0.0;
    long double sigmaInterTicks = 0.0;
    double tickTimeMicroSecs = 1000000.0/CPU_TicksPerSecond();
    debug_printf("Tick length = %eus\r\n",tickTimeMicroSecs);
    for(int i = 0; i < maxSamplesUsed-1; i++)
    {
        /*if(i<100)
        {
            debug_printf("execStartTicks[%u]=%u\r\n",i+1,execStartTicks[i+1]);
            debug_printf("-\r\nexecStartTicks[%u]=%u\r\n",i,execStartTicks[i]);
            debug_printf("=\r\n%u\r\n\r\n",(execStartTicks[i+1] - execStartTicks[i]));
        }*/
        avgInterTicks += (execStartTicks[i+1]-execStartTicks[i]);
        //debug_printf("avgInterTicks = %e\r\n",avgInterTicks);
    }
    avgInterTicks=avgInterTicks/(maxSamplesUsed-1);
    debug_printf("Avg Time between ISR executions = %eus\r\n",avgInterTicks*tickTimeMicroSecs);

    for(int i = 0; i < maxSamplesUsed; i++)
    {
        sigmaInterTicks += pow((execStartTicks[i+1] - execStartTicks[i])-avgInterTicks,2);
    }
    sigmaInterTicks = sqrt(sigmaInterTicks/maxSamplesUsed);
    debug_printf("Std Deviation in Times = %eus\r\n",sigmaInterTicks*tickTimeMicroSecs);
#endif
}
Esempio n. 2
0
void csvRunTestResults()
{
#if defined(TIME_DAC_ISR)
    UINT16 maxSamplesUsed = TEST_SAMPLES_NUM;

    double tickTimeMicroSecs = 1000000.0/CPU_TicksPerSecond();
    debug_printf("\r\n\r\n==========================================\r\n");
    for(int i = 0; i < maxSamplesUsed; i++)
    {
        debug_printf("%f,%f\r\n",execStartTicks[i]*tickTimeMicroSecs,(execStartTicks[i+1]-execStartTicks[i])*tickTimeMicroSecs);
        //debug_printf("%f\r\n",execStartTicks[i]*tickTimeMicroSecs);
    }
    debug_printf("\r\n\r\n==========================================\r\n");
#endif
}
void __section("SectionForFlashOperations") Native_Profiler_Init()
{
    s_native_profiler.ticksPerMicrosecond = CPU_TicksPerSecond() / 1000000;
    unsigned int availableSpace   = &ProfilerBufferEnd - &ProfilerBufferBegin;
    s_native_profiler.useBuffer   = FALSE;
    s_native_profiler.initTime    = Native_Profiler_TimeInMicroseconds();
    s_native_profiler.writtenData = FALSE;

    if(availableSpace >= 10)
    {
        GLOBAL_LOCK(irq);
        
        s_native_profiler.useBuffer = TRUE;
        s_native_profiler.isOn      = TRUE;
        UINT64 timeBegin;
        UINT64 timeEnd;
        UINT64 timeToGetTicks;
        s_native_profiler.position = &ProfilerBufferBegin;

        // Measure time introduced by profiling.

        timeToGetTicks              = Time_CurrentTicks();
        timeBegin                   = Time_CurrentTicks();
        {
            Native_Profiler testObj;
        }
        {
            Native_Profiler testObj;
        }
        timeEnd                     = Time_CurrentTicks();
        
        // Count mean time spend in Native_Profiler constructor and destructor.
        s_native_profiler.engineTimeOffset = (UINT32)((timeEnd - timeBegin - 2 * (timeBegin - timeToGetTicks)) / (2 * s_native_profiler.ticksPerMicrosecond));
        s_native_profiler.position         = &ProfilerBufferBegin;
        *s_native_profiler.position++      = NATIVE_PROFILER_START_TAG;
        *s_native_profiler.position++      = s_native_profiler.engineTimeOffset;
        s_native_profiler.isOn             = FALSE;
    }
}
Esempio n. 4
0
UINT32 Events_WaitForEvents( UINT32 sleepLevel, UINT32 WakeupSystemEvents, UINT32 Timeout_Milliseconds )
{
    NATIVE_PROFILE_PAL_EVENTS();
    // do NOT call this routine with interrupts disabled,
    // as we can die here, since flags are only set in ISRs
    ASSERT_IRQ_MUST_BE_ON();

    // schedule an interrupt for this far in the future
    // timeout is in milliseconds, convert to Sleep Counts

    UINT64 CountsRemaining = CPU_MillisecondsToTicks( Timeout_Milliseconds );

#if defined(HAL_PROFILE_ENABLED)
    Events_WaitForEvents_Calls++;
#endif

    {
        GLOBAL_LOCK(irq);

        // then check to make sure the events haven't happened on the way in
        // we must do this before we sleep!

        UINT64 Expire           = HAL_Time_CurrentTicks() + CountsRemaining;
        BOOL   RunContinuations = TRUE;

        while(true)
        {
            UINT32 Events = Events_MaskedRead( WakeupSystemEvents ); if(Events) return Events;

            if(Expire <= HAL_Time_CurrentTicks()) return 0;


            // first check and possibly run any continuations
            // but only if we have slept after stalling
            if(RunContinuations && !SystemState_QueryNoLock( SYSTEM_STATE_NO_CONTINUATIONS ))
            {
                // restore interrupts before running a continuation
                irq.Release();

                // if we stall on time, don't check again until after we sleep
                RunContinuations = HAL_CONTINUATION::Dequeue_And_Execute();

                irq.Acquire();
            }
            else
            {
                // try stalled continuations again after sleeping
                RunContinuations = TRUE;

                //lcd_printf("\fSleep=%6lld   ", CountsRemaining);
                //lcd_printf(  "Events=%08x", Events_MaskedRead(0xffffffff));

#if defined(HAL_TIMEWARP)
                if(s_timewarp_lastButton < HAL_Time_TicksToTime( HAL_Time_CurrentTicks() ))
                {
                    CountsRemaining = Expire - HAL_Time_CurrentTicks();

                    if(CountsRemaining > 0)
                    {
                        s_timewarp_compensate += (CountsRemaining * 10*1000*1000) / CPU_TicksPerSecond();
                    }
                    return 0;
                }
#endif

                ASSERT_IRQ_MUST_BE_OFF();

                HAL_COMPLETION::WaitForInterrupts( Expire, sleepLevel, WakeupSystemEvents );

                irq.Probe(); // See if we have to serve any pending interrupts.                
            }
        }
    }
}
Esempio n. 5
0
BOOL LPC24XX_DAC_Driver::Off()
{
	if(g_LPC24XX_DAC_Driver.SampleTimeInCycles == 0) return FALSE;
	  
	ASSERT(LPC24XX_DAC::Timer < LPC24XX_TIMER_Driver::c_MaxTimers);

    GLOBAL_LOCK(irq);

    if(g_LPC24XX_TIMER_Driver.m_configured[LPC24XX_DAC::Timer] == FALSE) return FALSE;

    //--//
	
	//reset IRQ priority
	LPC24XX_VIC& VIC = LPC24XX::VIC();	
	VIC.VECTPRIORITY[LPC24XX_TIMER::getIntNo(LPC24XX_DAC::Timer)] = 0xF;
	
    if(!CPU_INTC_DeactivateInterrupt( LPC24XX_TIMER::getIntNo(LPC24XX_DAC::Timer) )) return FALSE;

    LPC24XX_TIMER& TIMER = LPC24XX::TIMER( LPC24XX_DAC::Timer );

    //Reset timer
    TIMER.TCR = 0x2;
	//Reset Match0 and Match Control regs
	TIMER.MR0 = 0x0;
	TIMER.MCR = 0x0;
    // disable Timer
    TIMER.TCR = 0;

    //--//

    
	g_LPC24XX_TIMER_Driver.m_configured[LPC24XX_DAC::Timer] = FALSE;

	#if defined(TIME_DAC_ISR)
	
	UINT16 maxSamplesUsed = 6400;
	long double avgInterTicks = 0.0;
	long double sigmaInterTicks = 0.0;
	double tickTimeMicroSecs = 1000000.0/CPU_TicksPerSecond();
	debug_printf("Tick length = %eus\r\n",tickTimeMicroSecs);
	for(int i = 0; i < maxSamplesUsed-1; i++)
	{
		/*if(i<100)
		{
			debug_printf("execStartTicks[%u]=%u\r\n",i+1,execStartTicks[i+1]);
			debug_printf("-\r\nexecStartTicks[%u]=%u\r\n",i,execStartTicks[i]);
			debug_printf("=\r\n%u\r\n\r\n",(execStartTicks[i+1] - execStartTicks[i]));
		}*/
		avgInterTicks += (execStartTicks[i+1]-execStartTicks[i]);
		//debug_printf("avgInterTicks = %e\r\n",avgInterTicks);
	}
	avgInterTicks=avgInterTicks/(maxSamplesUsed-1);
	debug_printf("Avg Time between ISR executions = %eus\r\n",avgInterTicks*tickTimeMicroSecs);
	
	for(int i = 0; i < maxSamplesUsed; i++)
	{
		sigmaInterTicks += pow((execStartTicks[i+1] - execStartTicks[i])-avgInterTicks,2);
	}
	sigmaInterTicks = sqrt(sigmaInterTicks/maxSamplesUsed);
	debug_printf("Std Deviation in Times = %eus\r\n",sigmaInterTicks*tickTimeMicroSecs);
	
	#endif
	
	#if defined(MONITOR_BUFFER_LEVEL)
	for(bufLevelMarkCount = 0; bufLevelMarkCount<80; bufLevelMarkCount++)
		debug_printf("%u\r\n",bufferLevel[bufLevelMarkCount]);
	bufLevelMarkCount = 0;
	#endif
    return TRUE;
}
/*----------------------------------------------------------------------*
                         rtp_get_system_sec
 *----------------------------------------------------------------------*/
unsigned long rtp_get_ticks_p_sec ()
{
    NATIVE_PROFILE_PAL_NETWORK();
    return CPU_TicksPerSecond();
}