Hello everyone, I have a problem with a project. It is a weekly time I found on the web.

It is originally written for ATMEGA16 but I used the "A" version of this chip.

The problem is that the two output ports (C4 and C5) that are supposed to be HIGH at the preset times, stay LOW!

Could it be because of wrong Fuse Bits? Or the chip is broken? Or maybe the code needs to modified for ATMEGA16A that i'm currently using?

I will appreciate any help.

Ciao!

Here is the code:

/***************************************************** This program was produced by the CodeWizardAVR V2.05.0 Professional Automatic Program Generator © Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 1988/01/01 Author : Company : Comments: Chip type : ATmega16 Program type : Application AVR Core Clock frequency: 8.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega16.h> #include <stdio.h> // I2C Bus functions #asm .equ __i2c_port=0x15 ;PORTC .equ __sda_bit=1 .equ __scl_bit=0 #endasm #include <i2c.h> // DS1307 Real Time Clock functions #include <ds1307.h> // Alphanumeric LCD Module functions #include <alcd.h> #define up PIND.0 #define down PIND.1 #define right PIND.4 #define left PIND.5 #define ok PIND.6 #define output1 PORTC.2 #define output2 PORTC.3 #define lcd_light PORTA.3 unsigned char clear=1,select_screen=15,set=0,count1=0,data[16],num_dsp1,num_dsp2,num_dsp3,num_dsp4; eeprom unsigned char perm1=0,perm2=0,perm3=0,perm4=0,perm5=0,perm6=0,perm7=0,perm8=0,perm9=0,perm10=0,perm11=0,perm12=0,perm13=0,perm14=0; unsigned char week_day [8][10]={" "," Monday "," Tuesday ","Wednesday"," Thursday"," Friday "," Saturday"," Sunday "}; eeprom char en1=0,en2=0,en3=0,en4=0,en5=0,en6=0,en7=0,en8=0,en9=0,en10=0,en11=0,en12=0,en13=0,en14=0; unsigned char year,month,day,week,hour,min,sec; eeprom int hour11=0,min11=0,hour12=0,min12=0,hour13=0,min13=0,hour14=0,min14=0,hour21=0,min21=0,hour22=0,min22=0,hour23=0,min23=0,hour24=0,min24=0,hour31=0,min31=0,hour32=0,min32=0,hour33=0,min33=0,hour34=0,min34=0,hour41=0,min41=0,hour42=0,min42=0,hour43=0,min43=0,hour44=0,min44=0; eeprom int hour51=0,min51=0,hour52=0,min52=0,hour53=0,min53=0,hour54=0,min54=0,hour61=0,min61=0,hour62=0,min62=0,hour63=0,min63=0,hour64=0,min64=0,hour71=0,min71=0,hour72=0,min72=0,hour73=0,min73=0,hour74=0,min74=0; void work () { ////////// Monday ///////////////// if((hour==hour11)&&(min==min11)&&(perm1==0)&&(en1==1)&&(week==1)) { perm1=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour12)&&(min==min12)&&(perm1==1)&&(week==1)) { perm1=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour13)&&(min==min13)&&(perm2==0)&&(en2==1)&&(week==1)) { perm2=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour14)&&(min==min14)&&(perm2==1)&&(week==1)) { perm2=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } ////////// Tuesday ///////////////// if((hour==hour21)&&(min==min21)&&(perm3==0)&&(en3==1)&&(week==2)) { perm3=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour22)&&(min==min22)&&(perm3==1)&&(week==2)) { perm3=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour23)&&(min==min23)&&(perm4==0)&&(en4==1)&&(week==2)) { perm4=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour24)&&(min==min24)&&(perm4==1)&&(week==2)) { perm4=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } ////////// wednesday ///////////////// if((hour==hour31)&&(min==min31)&&(perm5==0)&&(en5==1)&&(week==3)) { perm5=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour32)&&(min==min32)&&(perm5==1)&&(week==3)) { perm5=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour33)&&(min==min33)&&(perm6==0)&&(en6==1)&&(week==3)) { perm6=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour34)&&(min==min34)&&(perm6==1)&&(week==3)) { perm6=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } ////////// Thursday ///////////////// if((hour==hour41)&&(min==min41)&&(perm7==0)&&(en7==1)&&(week==4)) { perm7=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour42)&&(min==min42)&&(perm7==1)&&(week==4)) { perm7=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour43)&&(min==min43)&&(perm8==0)&&(en8==1)&&(week==4)) { perm8=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour44)&&(min==min44)&&(perm8==1)&&(week==4)) { perm8=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } ////////// Friday ///////////////// if((hour==hour51)&&(min==min51)&&(perm9==0)&&(en9==1)&&(week==5)) { perm9=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour52)&&(min==min52)&&(perm9==1)&&(week==5)) { perm9=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour53)&&(min==min53)&&(perm10==0)&&(en10==1)&&(week==5)) { perm10=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour54)&&(min==min54)&&(perm10==1)&&(week==5)) { perm10=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } ////////// Saturday ///////////////// if((hour==hour61)&&(min==min61)&&(perm11==0)&&(en11==1)&&(week==6)) { perm11=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour62)&&(min==min62)&&(perm11==1)&&(week==6)) { perm11=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour63)&&(min==min63)&&(perm12==0)&&(en12==1)&&(week==6)) { perm12=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour64)&&(min==min64)&&(perm12==1)&&(week==6)) { perm12=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } ////////// Sunday ///////////////// if((hour==hour71)&&(min==min71)&&(perm13==0)&&(en13==1)&&(week==7)) { perm13=1; output1=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour72)&&(min==min72)&&(perm13==1)&&(week==7)) { perm13=0; output1=0; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour73)&&(min==min73)&&(perm14==0)&&(en14==1)&&(week==7)) { perm14=1; output2=1; lcd_light=1; TCCR1B=0x03; count1=0; } if((hour==hour74)&&(min==min74)&&(perm14==1)&&(week==7)) { perm14=0; output2=0; lcd_light=1; TCCR1B=0x03; count1=0; } } void show () { switch(select_screen) { case 1: lcd_gotoxy(0,0); if(en1==0) lcd_putsf(" Mon No.1:off "); if(en1==1) lcd_putsf(" Mon No.1:on "); num_dsp1=hour11; num_dsp2=min11; num_dsp3=hour12; num_dsp4=min12; break; case 2: lcd_gotoxy(0,0); if(en2==0) lcd_putsf(" Mon No.2:off "); if(en2==1) lcd_putsf(" Mon No.2:on "); num_dsp1=hour13; num_dsp2=min13; num_dsp3=hour14; num_dsp4=min14; break; case 3: lcd_gotoxy(0,0); if(en3==0) lcd_putsf(" Tue No.1:off "); if(en3==1) lcd_putsf(" Tue No.1:on "); num_dsp1=hour21; num_dsp2=min21; num_dsp3=hour22; num_dsp4=min22; break; case 4: lcd_gotoxy(0,0); if(en4==0) lcd_putsf(" Tue No.2:off "); if(en4==1) lcd_putsf(" Tue No.2:on "); num_dsp1=hour23; num_dsp2=min23; num_dsp3=hour24; num_dsp4=min24; break; case 5: lcd_gotoxy(0,0); if(en5==0) lcd_putsf(" Wed No.1:off "); if(en5==1) lcd_putsf(" Wed No.1:on "); num_dsp1=hour31; num_dsp2=min31; num_dsp3=hour32; num_dsp4=min32; break; case 6: lcd_gotoxy(0,0); if(en6==0) lcd_putsf(" Wed No.2:off "); if(en6==1) lcd_putsf(" Wed No.2:on "); num_dsp1=hour33; num_dsp2=min33; num_dsp3=hour34; num_dsp4=min34; break; case 7: lcd_gotoxy(0,0); if(en7==0) lcd_putsf(" Thu No.1:off "); if(en7==1) lcd_putsf(" Thu No.1:on "); num_dsp1=hour41; num_dsp2=min41; num_dsp3=hour42; num_dsp4=min42; break; case 8: lcd_gotoxy(0,0); if(en8==0) lcd_putsf(" Thu No.2:off "); if(en8==1) lcd_putsf(" Thu No.2:on "); num_dsp1=hour43; num_dsp2=min43; num_dsp3=hour44; num_dsp4=min44; break; case 9: lcd_gotoxy(0,0); if(en9==0) lcd_putsf(" Fri No.1:off "); if(en9==1) lcd_putsf(" Fri No.1:on "); num_dsp1=hour51; num_dsp2=min51; num_dsp3=hour52; num_dsp4=min52; break; case 10: lcd_gotoxy(0,0); if(en10==0) lcd_putsf(" Fri No.2:off "); if(en10==1) lcd_putsf(" Fri No.2:on "); num_dsp1=hour53; num_dsp2=min53; num_dsp3=hour54; num_dsp4=min54; break; case 11: lcd_gotoxy(0,0); if(en11==0) lcd_putsf(" Sat No.1:off "); if(en11==1) lcd_putsf(" Sat No.1:on "); num_dsp1=hour61; num_dsp2=min61; num_dsp3=hour62; num_dsp4=min62; break; case 12: lcd_gotoxy(0,0); if(en12==0) lcd_putsf(" Sat No.2:off "); if(en12==1) lcd_putsf(" Sat No.2:on "); num_dsp1=hour63; num_dsp2=min63; num_dsp3=hour64; num_dsp4=min64; break; case 13: lcd_gotoxy(0,0); if(en13==0) lcd_putsf(" Sun No.1:off "); if(en13==1) lcd_putsf(" Sun No.1:on "); num_dsp1=hour71; num_dsp2=min71; num_dsp3=hour72; num_dsp4=min72; break; case 14: lcd_gotoxy(0,0); if(en14==0) lcd_putsf(" Sun No.2:off "); if(en14==1) lcd_putsf(" Sun No.2:on "); num_dsp1=hour73; num_dsp2=min73; num_dsp3=hour74; num_dsp4=min74; break; case 15: if(set==0) { if(clear==1) { lcd_clear(); clear=0; } sprintf(data,"%s",week_day[week]); lcd_gotoxy(3,0); lcd_puts(data); sprintf(data,"Time is %02d:%02d:%02d",hour,min,sec); lcd_gotoxy(0,1); lcd_puts(data); break; } if(set==1) { sprintf(data,"%s",week_day[week]); lcd_gotoxy(3,0); lcd_puts(data); lcd_gotoxy(0,1); lcd_putsf("Time is --:--:--"); clear=1; break; } if(set==2) { if(clear==1) { lcd_clear(); clear=0; } lcd_gotoxy(0,0); lcd_putsf(" ---------- "); sprintf(data,"Time is %02d:--:--",hour); lcd_gotoxy(0,1); lcd_puts(data); break; } if(set==3) { lcd_gotoxy(0,0); lcd_putsf(" ---------- "); sprintf(data,"Time is --:%02d:--",min); lcd_gotoxy(0,1); lcd_puts(data); break; } if(set==4) { lcd_gotoxy(0,0); lcd_putsf(" ---------- "); sprintf(data,"Time is --:--:%02d",sec); lcd_gotoxy(0,1); lcd_puts(data); clear=1; break; } } if(select_screen<15) { if(set==0) { sprintf(data,"%02d:%02d to %02d:%02d",num_dsp1,num_dsp2,num_dsp3,num_dsp4); lcd_gotoxy(0,1); lcd_puts(data); } if(set==1) { sprintf(data,"%02d:-- to --:--",num_dsp1); lcd_gotoxy(0,1); lcd_puts(data); } if(set==2) { sprintf(data,"--:%02d to --:--",num_dsp2); lcd_gotoxy(0,1); lcd_puts(data); } if(set==3) { sprintf(data,"--:-- to %02d:--",num_dsp3); lcd_gotoxy(0,1); lcd_puts(data); } if(set==4) { sprintf(data,"--:-- to --:%02d",num_dsp4); lcd_gotoxy(0,1); lcd_puts(data); } } } void keypad() { if(up==0) { if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end1; } count1=0; switch(select_screen) { case 1: if(set==0) { en1=1; } if(set==1) { hour11++; if(hour11>23) hour11=0; } if(set==2) { min11++; if(min11>59) min11=0; } if(set==3) { hour12++; if(hour12>23) hour12=0; } if(set==4) { min12++; if(min12>59) min12=0; } break; case 2: if(set==0) { en2=1; } if(set==1) { hour13++; if(hour13>23) hour13=0; } if(set==2) { min13++; if(min13>59) min13=0; } if(set==3) { hour14++; if(hour14>23) hour14=0; } if(set==4) { min14++; if(min14>59) min14=0; } break; case 3: if(set==0) { en3=1; } if(set==1) { hour21++; if(hour21>23) hour21=0; } if(set==2) { min21++; if(min21>59) min21=0; } if(set==3) { hour22++; if(hour22>23) hour22=0; } if(set==4) { min22++; if(min22>59) min22=0; } break; case 4: if(set==0) { en4=1; } if(set==1) { hour23++; if(hour23>23) hour23=0; } if(set==2) { min23++; if(min23>59) min23=0; } if(set==3) { hour24++; if(hour24>23) hour24=0; } if(set==4) { min24++; if(min24>59) min24=0; } break; case 5: if(set==0) { en5=1; } if(set==1) { hour31++; if(hour31>23) hour31=0; } if(set==2) { min31++; if(min31>59) min31=0; } if(set==3) { hour32++; if(hour32>23) hour32=0; } if(set==4) { min32++; if(min32>59) min32=0; } break; case 6: if(set==0) { en6=1; } if(set==1) { hour33++; if(hour33>23) hour33=0; } if(set==2) { min33++; if(min33>59) min33=0; } if(set==3) { hour34++; if(hour34>23) hour34=0; } if(set==4) { min34++; if(min34>59) min34=0; } break; case 7: if(set==0) { en7=1; } if(set==1) { hour41++; if(hour41>23) hour41=0; } if(set==2) { min41++; if(min41>59) min41=0; } if(set==3) { hour42++; if(hour42>23) hour42=0; } if(set==4) { min42++; if(min42>59) min42=0; } break; case 8: if(set==0) { en8=1; } if(set==1) { hour43++; if(hour43>23) hour43=0; } if(set==2) { min43++; if(min43>59) min43=0; } if(set==3) { hour44++; if(hour44>23) hour44=0; } if(set==4) { min44++; if(min44>59) min44=0; } break; case 9: if(set==0) { en9=1; } if(set==1) { hour51++; if(hour51>23) hour51=0; } if(set==2) { min51++; if(min51>59) min51=0; } if(set==3) { hour52++; if(hour52>23) hour52=0; } if(set==4) { min52++; if(min52>59) min52=0; } break; case 10: if(set==0) { en10=1; } if(set==1) { hour53++; if(hour53>23) hour53=0; } if(set==2) { min53++; if(min53>59) min53=0; } if(set==3) { hour54++; if(hour54>23) hour54=0; } if(set==4) { min54++; if(min54>59) min54=0; } break; case 11: if(set==0) { en11=1; } if(set==1) { hour61++; if(hour61>23) hour61=0; } if(set==2) { min61++; if(min61>59) min61=0; } if(set==3) { hour62++; if(hour62>23) hour62=0; } if(set==4) { min62++; if(min62>59) min62=0; } break; case 12: if(set==0) { en12=1; } if(set==1) { hour63++; if(hour63>23) hour63=0; } if(set==2) { min63++; if(min63>59) min63=0; } if(set==3) { hour64++; if(hour64>23) hour64=0; } if(set==4) { min64++; if(min64>59) min64=0; } break; case 13: if(set==0) { en13=1; } if(set==1) { hour71++; if(hour71>23) hour71=0; } if(set==2) { min71++; if(min71>59) min71=0; } if(set==3) { hour72++; if(hour72>23) hour72=0; } if(set==4) { min72++; if(min72>59) min72=0; } break; case 14: if(set==0) { en14=1; } if(set==1) { hour73++; if(hour73>23) hour73=0; } if(set==2) { min73++; if(min73>59) min73=0; } if(set==3) { hour74++; if(hour74>23) hour74=0; } if(set==4) { min74++; if(min74>59) min74=0; } break; case 15: if(set==1) { week++; lcd_clear(); if(week>7) week=1; rtc_set_date(week,day,month,year); } if(set==2) { hour++; if(hour>23) hour=0; rtc_set_time(hour,min,sec); } if(set==3) { min++; if(min>59) min=0; rtc_set_time(hour,min,sec); } if(set==4) { sec++; if(sec>59) sec=0; rtc_set_time(hour,min,sec); } break; } end1: while(!up); } if(down==0) { if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end2; } count1=0; switch(select_screen) { case 1: if(set==0) { en1=0; } if(set==1) { hour11--; if(hour11<0) hour11=23; } if(set==2) { min11--; if(min11<0) min11=59; } if(set==3) { hour12--; if(hour12<0) hour12=23; } if(set==4) { min12--; if(min12<0) min12=59; } break; case 2: if(set==0) { en2=0; } if(set==1) { hour13--; if(hour13<0) hour13=23; } if(set==2) { min13--; if(min13<0) min13=59; } if(set==3) { hour14--; if(hour14<0) hour14=23; } if(set==4) { min14--; if(min14<0) min14=59; } break; case 3:if(set==0) { en3=0; } if(set==1) { hour21--; if(hour21<0) hour21=23; } if(set==2) { min21--; if(min21<0) min21=59; } if(set==3) { hour22--; if(hour22<0) hour22=23; } if(set==4) { min22--; if(min22<0) min22=59; } break; case 4: if(set==0) { en4=0; } if(set==1) { hour23--; if(hour23<0) hour23=23; } if(set==2) { min23--; if(min23<0) min23=59; } if(set==3) { hour24--; if(hour24<0) hour24=23; } if(set==4) { min24--; if(min24<0) min24=59; } break; case 5: if(set==0) { en5=0; } if(set==1) { hour31--; if(hour31<0) hour31=23; } if(set==2) { min31--; if(min31<0) min31=59; } if(set==3) { hour32--; if(hour32<0) hour32=23; } if(set==4) { min32--; if(min32<0) min32=59; } break; case 6: if(set==0) { en6=0; } if(set==1) { hour33--; if(hour33<0) hour33=23; } if(set==2) { min33--; if(min33<0) min33=59; } if(set==3) { hour34--; if(hour34<0) hour34=23; } if(set==4) { min34--; if(min34<0) min34=59; } break; case 7: if(set==0) { en7=0; } if(set==1) { hour41--; if(hour41<0) hour41=23; } if(set==2) { min41--; if(min41<0) min41=59; } if(set==3) { hour42--; if(hour42<0) hour42=23; } if(set==4) { min42--; if(min42<0) min42=59; } break; case 8: if(set==0) { en8=0; } if(set==1) { hour43--; if(hour43<0) hour43=23; } if(set==2) { min43--; if(min43<0) min43=59; } if(set==3) { hour44--; if(hour44<0) hour44=23; } if(set==4) { min44--; if(min44<0) min44=59; } break; case 9: if(set==0) { en9=0; } if(set==1) { hour51--; if(hour51<0) hour51=23; } if(set==2) { min51--; if(min51<0) min51=59; } if(set==3) { hour52--; if(hour52<0) hour52=23; } if(set==4) { min52--; if(min52<0) min52=59; } break; case 10: if(set==0) { en10=0; } if(set==1) { hour53--; if(hour53<0) hour53=23; } if(set==2) { min53--; if(min53<0) min53=59; } if(set==3) { hour54--; if(hour54<0) hour54=23; } if(set==4) { min54--; if(min54<0) min54=59; } break; case 11: if(set==0) { en11=0; } if(set==1) { hour61--; if(hour61<0) hour61=23; } if(set==2) { min61--; if(min61<0) min61=59; } if(set==3) { hour62--; if(hour62<0) hour62=23; } if(set==4) { min62--; if(min62<0) min62=59; } break; case 12: if(set==0) { en12=0; } if(set==1) { hour63--; if(hour63<0) hour63=23; } if(set==2) { min63--; if(min63<0) min63=59; } if(set==3) { hour64--; if(hour64<0) hour64=23; } if(set==4) { min64--; if(min64<0) min64=59; } break; case 13: if(set==0) { en13=0; } if(set==1) { hour71--; if(hour71<0) hour71=23; } if(set==2) { min71--; if(min71<0) min71=59; } if(set==3) { hour72--; if(hour72<0) hour72=23; } if(set==4) { min72--; if(min72<0) min72=59; } break; case 14: if(set==0) { en14=0; } if(set==1) { hour73--; if(hour73<0) hour73=23; } if(set==2) { min73--; if(min73<0) min73=59; } if(set==3) { hour74--; if(hour74<0) hour74=23; } if(set==4) { min74--; if(min74<0) min74=59; } break; case 15: if(set==1) { week--; lcd_clear(); if(week<1) week=7; rtc_set_date(week,day,month,year); } if(set==2) { if(hour==0) { hour=23; goto lable1; } if(hour>0) hour--; lable1: rtc_set_time(hour,min,sec); } if(set==3) { if(min==0) { min=59; goto lable2; } if(min>0) min--; lable2: rtc_set_time(hour,min,sec); } if(set==4) { if(sec==0) { sec=59; goto lable3; } if(sec>0) sec--; lable3: rtc_set_time(hour,min,sec); } break; } end2: while(!down); } if(right==0) { if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end3; } count1=0; select_screen++; lcd_clear(); set=0; if(select_screen>15) select_screen=1; end3: while(!right); } if(left==0) { if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end4; } count1=0; select_screen--; lcd_clear(); set=0; if(select_screen<1) select_screen=15; end4: while(!left); } if(ok==0) { if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end5; } switch(select_screen) { case 1: en1=0; break; case 2: en2=0; break; case 3: en3=0; break; case 4: en4=0; break; case 5: en5=0; break; case 6: en6=0; break; case 7: en7=0; break; case 8: en8=0; break; case 9: en9=0; break; case 10: en10=0; break; case 11: en11=0; break; case 12: en12=0; break; case 13: en13=0; break; case 14: en14=0; break; } count1=0; set++; if(set>4) set=0; end5: while(!ok); } } // External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { // Place your code here //Reset All EEPROM if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end6; } count1=0; hour11=0; min11=0; hour12=0; min12=0; hour13=0; min13=0; hour14=0; min14=0; hour21=0; min21=0; hour22=0; min22=0; hour23=0; min23=0; hour24=0; min24=0; hour31=0; min31=0; hour32=0; min32=0; hour33=0; min33=0; hour34=0; min34=0; hour41=0; min41=0; hour42=0; min42=0; hour43=0; min43=0; hour44=0; min44=0; hour51=0; min51=0; hour52=0; min52=0; hour53=0; min53=0; hour54=0; min54=0; hour61=0; min61=0; hour62=0; min62=0; hour63=0; min63=0; hour64=0; min64=0; hour71=0; min71=0; hour72=0; min72=0; hour73=0; min73=0; hour74=0; min74=0; lcd_clear(); show(); end6: } // External Interrupt 1 service routine interrupt [EXT_INT1] void ext_int1_isr(void) { // Place your code here if(lcd_light==0) { lcd_light=1; TCCR1B=0x03; count1=0; goto end7; } count1=0; //Reset this screen EEPROM switch(select_screen) { case 1: hour11=0; min11=0; hour12=0; min12=0; break; case 2: hour13=0; min13=0; hour14=0; min14=0; break; case 3: hour21=0; min21=0; hour22=0; min22=0; break; case 4: hour23=0; min23=0; hour24=0; min24=0; break; case 5: hour31=0; min31=0; hour32=0; min32=0; break; case 6: hour33=0; min33=0; hour34=0; min34=0; break; case 7: hour41=0; min41=0; hour42=0; min42=0; break; case 8: hour43=0; min43=0; hour44=0; min44=0; break; case 9: hour51=0; min51=0; hour52=0; min52=0; break; case 10: hour53=0; min53=0; hour54=0; min54=0; break; case 11: hour61=0; min61=0; hour62=0; min62=0; break; case 12: hour63=0; min63=0; hour64=0; min64=0; break; case 13: hour71=0; min71=0; hour72=0; min72=0; break; case 14: hour73=0; min73=0; hour74=0; min74=0; break; case 15: week=1; hour=0; min=0; sec=0; rtc_set_time(hour,min,sec); rtc_set_date(week,day,month,year); lcd_clear(); show(); break; } end7: } // External Interrupt 2 service routine interrupt [EXT_INT2] void ext_int2_isr(void) { // Place your code here } // Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isr(void) { // Reinitialize Timer 0 value TCNT0=0x05; // Place your code here } // Timer1 overflow interrupt service routine interrupt [TIM1_OVF] void timer1_ovf_isr(void) { // Place your code here count1++; if(count1>20) { count1=0; TCCR1B=0x00; lcd_light=0; } } // Timer2 overflow interrupt service routine interrupt [TIM2_OVF] void timer2_ovf_isr(void) { // Place your code here } // Declare your global variables here void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x08; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x30; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: 31.250 kHz // Mode: Normal top=0xFF // OC0 output: Disconnected //TCCR0=0x04; TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 125.000 kHz // Mode: Normal top=0xFFFF // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: On // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; //TCCR1B=0x03; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: 125.000 kHz // Mode: Normal top=0xFF // OC2 output: Disconnected ASSR=0x00; //TCCR2=0x04; TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: On // INT0 Mode: Falling Edge // INT1: On // INT1 Mode: Falling Edge // INT2: On // INT2 Mode: Falling Edge GICR|=0xE0; MCUCR=0x0A; MCUCSR=0x00; GIFR=0xE0; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x45; // USART initialization // USART disabled UCSRB=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // ADC initialization // ADC disabled ADCSRA=0x00; // SPI initialization // SPI disabled SPCR=0x00; // TWI initialization // TWI disabled TWCR=0x00; // I2C Bus initialization i2c_init(); // DS1307 Real Time Clock initialization // Square wave output on pin SQW/OUT: Off // SQW/OUT pin state: 0 rtc_init(0,0,0); // Alphanumeric LCD initialization // Connections specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTA Bit 0 // RD - PORTA Bit 1 // EN - PORTA Bit 2 // D4 - PORTA Bit 4 // D5 - PORTA Bit 5 // D6 - PORTA Bit 6 // D7 - PORTA Bit 7 // Characters/line: 16 lcd_init(16); // Global enable interrupts #asm("sei") lcd_light=1; TCCR1B=0x03; count1=0; while (1) { // Place your code here keypad(); work(); rtc_get_time(&hour,&min,&sec); rtc_get_date(&week,&day,&month,&year); show(); } }