/*
* File: config.c
* Author: Alejo S. Giles
*
* Created on 3 de mayo de 2020, 21:17
*
* UNLPam - Fac. Ing - Computación II
*
* PIC18F46K20
*
* Compilador XC8 - Standard C 90
*
* Seleccionar Estandard C = C90 en las propiedades del proyecto:
* Files --> Projecto Properties --> XC8 Global Options --> C standard = C 90
*/
#include "config.h"
unsigned long centiseg=0; //Para el control de tiempos
void recargar_timer(void)
{
TMR0H = 0x3C;
TMR0L = 0xB0;
}
void timer0_config(void)
{
// Timer0 Registers:
// Prescaler=1:32; TMR0 Preset=128; Freq=976,5625Hz; Period=1.024,00 µs
//CONFIGURACION TIMER 0
T0CONbits.TMR0ON = 1;
T0CONbits.T08BIT = 0;
T0CONbits.T0CS = 0;
T0CONbits.T0SE = 0;
T0CONbits.PSA = 0;
T0CONbits.T0PS = 1;
TMR0H = 0x3C;
TMR0L = 0xB0;
INTCON = 0;
INTCONbits.TMR0IE = 1;
INTCONbits.TMR0IF = 0;
TMR0IE = 1;
TMR0 = TMR0_PREVALUE; // preset for timer register
}
void setup(void)
{
OSCCON = 0b01101100; //Configuración del oscilador
ANSEL=0; //Deshabilitación de canales analógicos
ANSELH=0; //Deshabilitación de canales analógicos
timer0_config();
INTCONbits.GIE = 1;
}
//RUTINA DE INTERRUPCION
void high_priority interrupt High_Priority_Interrupt(void) //File-->Project Properties-->XC8 Global Options --> C Standard --> C 90
{
if (HAY_INTERRUPCION)
{
LIMPIAR_BANDERA_INTERRUPCION;
centiseg++;
recargar_timer();
}
return;
}