Académique Documents
Professionnel Documents
Culture Documents
* File: CONTADOR.c
* Author: Esteban
*/
// CONFIG
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM
code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off;
all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection
off)
#include <xc.h>
#include <stdio.h>
#include <math.h>
int imprimir(int Display[], int UDC[], int contTiempo)
TMR0=0;
PORTD = Display[UDC[i]];
PORTA = pow(2,i);
PORTA = 0;
contTiempo++;
return contTiempo;
}
void main(void) {
int UDC[3]={{0},{0},{0}};
int Display[16]={{0b01000000},
{0b01111001},
{0b00100100},
{0b00110000},
{0b00011001},
{0b00010010},
{0b00000010},
{0b01111000},
{0b00000000},
{0b00010000},
{0b01111111},
{0b01111111},
{0b01111111},
{0b01111111},
{0b01111111},
{0b01111111}};
ADCON1 = 6;
OPTION_REG=0b11010111; //cambio el preescalador y seteo el TMR0 para el barrido de
display
while(1)
if (contTiempo = 10000000)
unidades++;
if (unidades == 10)
decenas++;
unidades = 0;
if(decenas == 10)
centenas++;
decenas = 0;
{
unidades=0;
decenas=0;
centenas=0;
UDC[0]=unidades;
UDC[1]=decenas;
UDC[2]=centenas;
return;