Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Codigo Proyecto
Codigo Proyecto
set_timer0 ( cargaTMR0 );
if ( contDelay > 0 )
{
contDelay --;
}
else
{
LED = 0 ;
BUZZ = 0 ;
}
}
void main ()
{
int i ;
//configuracion de puertos de entrada/salida
set_tris_a ( 0xFF );
set_tris_b ( 0xFF );
set_tris_c ( 0xFF );
set_tris_d ( 0xFF );
tbtn1 = 1 ;
tLED = 0 ;
tBUZZ = 0 ;
//resistencia PULL-UP
_RBPU = 0 ;
//configuracion de los TIMERs
LED = 1 ;
enable_interrupts ( GLOBAL | PERIPH | INT_TIMER0 );
enable_interrupts ( INT_EXT_H2L );
enable_interrupts ( INT_TIMER1 );
SETUP_TIMER_1 ( T1_INTERNAL | T1_DIV_BY_8 );
SETUP_TIMER_0 ( T0_INTERNAL | T0_DIV_256 );
//presentacion en pantalla
lcd_init ();
led = 1 ;
lcd_gotoxy ( 4 , 1 );
printf ( lcd_putc , "Espinoza" );
lcd_gotoxy ( 5 , 2 );
printf ( lcd_putc , "Macias" );
delay_ms ( 750 );
led = 0 ;
printf ( lcd_putc , "\f" );
//carga de TIMERs e inicializacion de vcariables
set_timer1 ( cargaTMR1 );
set_timer0 ( cargaTMR0 );
contTMR1 = 9 ;
contSeg = 19 ;
contDelay = 0 ;
contador2 = contador = 0 ;
//programa principal
while ( 1 )
{
if ( btn1 == 0 )
{
contTMR1 = 9 ; //1 segundo
contSeg = 19 ;
contador2 = 0 ;
contador = 0 ;
}
lcd_gotoxy ( 1 , 1 );
printf ( lcd_putc , "%4lu pulsos" , contador );
lcd_gotoxy ( 15 , 1 );
printf ( lcd_putc , "%2d" , contSeg );
lcd_gotoxy ( 1 , 2 );
printf ( lcd_putc , "%5lu PPM" , contador2 * 3 );
delay_ms ( 200 );
}
}