In software side, it is multiplex, xc8 comp to disp HH:MM:SEC, mcu reading from rtc readng at 24hrs format and then in software it is converted to 12hrs farmat.
H/W, 7seg CC, RTC1307.
All are working correctly , now I want to add a feature that is, when the time reach at 2:30 (at night)the disp will be turned OFF and after 2:32 (at night) the disp will turn ON. The code attched here is working all the said time(ie, as every 2.30 start OFF and evert 2.32 start ON), whereas i need only at night, so if 1st time is turned ON and OFF then for 2nd time(which is day time) no need and vice-versa, and 3rd. time what was in 1st time.
As per code attached here, Once turned OFF at said time at 2.30 & it ON at 2.32, when it ON then i set the time by BUTTON once to keep ON the disp for this 2nd. time but it going OFF again.
S, is the code ok or what should i modify either at BUTTON rour or Main routine.
Code is at Main()
// TIME FORMAT 24>>12 HRS
if (hour <= 12)
hour = hour;
PowerSave = 1;
PowerSave = 0;
hour = (hour - 12);
// For particular time display to be TURNED OFF and Again ON
if (PowerSave == 1)
if ((hour == 2 && min >= 30) && (hour == 2 && min <= 31))
INTCONbits.T0IE = 0;
INTCONbits.T0IE = 1;
Sub routine for BUTTON
uint8_t edit(uint8_t parameter)
while(debounce()); // call debounce function (wait for B1 to be released)
while(!BUTTON2) // if button B2 is pressed
__delay_ms(300); //this delay for prevent several count on one press
if (i == 0 && parameter <= 12)
PowerSave &= 0x01;
if(i == 0 && parameter > 12) // if hours > 23 ==> hours = 0
parameter = 1;
if(i == 1 && parameter > 59) // if minutes > 59 ==> minutes = 0
parameter = 0;
if (i == 0)
hour_1 = (parameter % 10);
hour_10 = (parameter / 10);
if (i == 1)
min_1 = (parameter % 10);
min_10 = (parameter / 10);
__delay_ms(10); //delay from 200 to 10 minimize to prevent blink on when update time
if(!BUTTON1) // if button B1 is pressed
if(debounce()) // call debounce function (make sure if B1 is pressed)
i++; // increment 'i' for the next parameter
return parameter; // return parameter value and exit