Hi guys i want to make a countdown timer for my uv box. I want to write it in ccs c language. As far as i know i need to use timer1 to make it real time. And i know how to use timer1 pin but i can write the digits which timer1 counts to a seven segment display. Can you guys please tell me how to do that?
My timer 1 code as an example but is just for blinking a led with timer one so i need to implement seven segment to that code for example?
Moderators note: used code tags for C
My timer 1 code as an example but is just for blinking a led with timer one so i need to implement seven segment to that code for example?
C:
#include <16f877.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay (clock=4000000)
#use fast_io(b)
int i=0;
#int_timer1
void timer1_kesme ()
{
set_timer1(63036);
i++;
if (i==50)
output_high(pin_b0);
if (i==100)
{
output_low(pin_b0);
i=0;
}
}
void main ( )
{
setup_psp(PSP_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_CCP1(CCP_OFF);
set_tris_b(0x00);
output_b(0x00);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
set_timer1(63036);
enable_interrupts(INT_timer1);
enable_interrupts(GLOBAL);
while(1);
}
Last edited: