Aqui te presento el programa para realizar un contador automatico que cuenta de 0 a 99 , puedes modificarlo a gusto para lo que necesites , lo que si esta en xc8 para pic 16f88 , se puede alterar facilmente .
Saludos
/*
* File: 2Segmentedisplay.c
* Author: nahueldiaz
*
* Created on 9 de septiembre de 2015, 09:38
*/
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
// CONFIG1
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital I/O, MCLR internally tied to VDD)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB0 // CCP1 Pin Selection bit (CCP1 function on RB0)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
// CONFIG2
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)
#pragma config IESO = ON // Internal External Switchover bit (Internal External Switchover mode enabled)
#define _XTAL_FREQ 8000000
unsigned char s,j,i ;
unsigned char display (unsigned char no){
unsigned char patern;
unsigned char segment[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
patern = segment[no];
return (patern);
}
unsigned char cnt,msb,lsb ;
void main ()
{
ANSEL = 0x00 ;
TRISA = 0x00 ;
TRISB = 0x00 ;
PORTA = 0x00 ;
PORTB = 0x00 ;
for(;;){
for (cnt=0;cnt<99;cnt++){
msb = cnt /10 ;
PORTB = display(msb);
PORTAbits.RA0 = 1 ;
__delay_ms(50);
PORTAbits.RA0 = 0 ;
lsb = cnt % 10;
PORTB = display(lsb);
PORTAbits.RA1 = 1;
__delay_ms(50);
PORTAbits.RA1 = 0;
__delay_ms(50);
}}}