Control de tiempo bsico - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Control de tiempo bsico

Description:

... de tiempo. b sico ... el reset del RTC (real time clock), pero despu s son mantenidas por el ... Unsigned long tiempo: segundos desde el 1 de enero ... – PowerPoint PPT presentation

Number of Views:106
Avg rating:3.0/5.0
Slides: 10
Provided by: Univer88
Category:
Tags: bsico | control | el | tiempo

less

Transcript and Presenter's Notes

Title: Control de tiempo bsico


1
Control de tiempobásico
2
Variables globales
  • SEC_TIMER, MS_TIMER y TICK_TIMER (1/1024
    segundos) son variables shared del sistema.
  • Son unsigned long
  • Se leen tras el reset del RTC (real time clock),
    pero después son mantenidas por el sistema.
  • No modificarlas (las usa TCP/IP, cofunciones,
    etc)

3
Ejemplo 1
  • define N 10000
  • main() timeit()
  • nodebug timeit()
  • unsigned long int T0
  • float T2,T1
  • int x,y
  • int i
  • T0 MS_TIMER
  • for(i0iltNi)
  • // T1 gives empty loop time
  • T1(MS_TIMER-T0)
  • T0 MS_TIMER
  • for(i0iltNi) xy
  • // T2 gives test code execution time
  • T2(MS_TIMER-T0)
  • // subtract empty loop time and convert to time
    for single pass
  • T2(T2-T1)/(float)N
  • // multiply by 1000 to convert milliseconds to
    microseconds.
  • printf("time to execute test code f
    us\n",T21000.0)

4
Ejemplo 2
  • void msDelay(unsigned int delay)
  • unsigned long done_time
  • done_time MS_TIMER delay
  • while( (long) (MS_TIMER - done_time) lt 0 )

5
Variables RTC
  • Unsigned long tiempo segundos desde el 1 de
    enero de 1980
  • struct tm char tm_sec     // seconds 0-59char
    tm_min     // 0-59char tm_hour    // 0-23char
    tm_mday    // 1-31char tm_mon     // 1-12char
    tm_year    // 80-147 (1980-2047)char
    tm_wday    // 0-6 0Sunday

6
Funciones RTC
  • tiempo
  • struct tm
  • SEC_TIMER

read_rtc( void )
RTC
int tm_rd( struct tm t )
Inicio
7
Funciones RTC
  • tiempo
  • struct tm
  • SEC_TIMER

void write_rtc( unsigned long int time )
RTC
int tm_wr( struct tm t )
8
Funciones RTC
  • tiempo
  • struct tm
  • SEC_TIMER

unsigned long mktime( struct tm timeptr )
unsigned int mktm( struct tm timeptr, unsigned
long time )
int tm_rd( struct tm t )
9
Funciones RTC

int rtc_timezone( long seconds, char tzname
) Description This function returns the
timezone offset as known by the library. The
timezone is obtained from the following sources,
in order of preference 1. The DHCP server.
This can only be used if the TCP/IP stack is in
use, and USE_DHCP is defined.2. The TIMEZONE
macro. This should be defined by the program to
an _hour_ offset - may be floating point.
Write a Comment
User Comments (0)
About PowerShow.com