temp=(miao)/10*16+(miao)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x80,0x80|temp); //Write the adjusted second data BCD code to the second register 80H in DS1302
write_1302(0x8e,0x80); //Open write protection
//write_1602com(0x0b);
break;
case 5:
fen--;
if(fen==-1)
fen=59;
write_sfm(3,fen);
write_1602com(er+4); //Because the LCD mode is set to write data, the pointer automatically increases by one, so here it is written back to the original position
temp=(fen)/10*16+(fen)%10; //Convert decimal to DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x82,temp); //Write the adjusted sub-data BCD code to the sub-register 82H in DS1302
write_1302(0x8e,0x80); //Open write protection
break;
case 4:
he--;
if(shi==-1)
it=23;
write_sfm(0,shi);
temp=(shi)/10*16+(shi)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x84,temp); //Write the adjusted hour data BCD code to hour register 84H in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(er+1); //Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
/*
case 4:week--;
if(week==0)
week=7;
write_1602com(yh+0x0C); //Specify the position of weekly data display after 'add'
write_week(week); //Specify the weekly data display content
temp=(week)/10*16+(week)%10; //Convert decimal to DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x8a,temp); //Write the adjusted week data BCD code to the week register 8aH in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+0x0e);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
*/
case 3:
ri--;
if((yue==1)||(yue==3)||(yue==5)||(yue==7)||(yue==8)||(yue==10)||(yue==12))
{
if(ri==0)
ri=31;
}
else
{
if(yue==2)
{
if(p_r==1)
{
if(ri==0)
ri=29;
}
else
{
if(ri==0)
ri=28;
}
}
else
{
if(ri==0)
ri=30;
}
}
Conver_week(nian,yue,ri);
write_week(week);
write_nyr(9,ri);
temp=(ri)/10*16+(ri)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x86,temp); //Write the adjusted date data BCD code to date register 86H in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+10);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
case 2:
yue--;
if(yue==0)
yue=12;
if((yue==4)||(yue==6)||(yue==9)||(yue==11))
{
if(ri>30)
ri=1;
}
else
{
if(yue==2)
{
if(p_r==1)
{
if(ri>29)
ri=1;
}
else
{
if(ri>28)
ri=1;
}
}
}
Conver_week(nian,yue,ri);
write_week(week);
write_nyr(6,yue);
temp=(yue)/10*16+(yue)%10; //Convert decimal into DCB code required by DS1302
write_1302(0x8e,0x00); //Allow writing, disable write protection
write_1302(0x88,temp); //Write the adjusted month data BCD code to month register 88H in DS1302
write_1302(0x8e,0x80); //Open write protection
write_1602com(yh+7);//Because the LCD mode is set to write data, the pointer automatically increases by one, so the cursor needs to return to its original position
break;
case 1:
our--
if(nian==-1)
ours=99;
nian_temp=2000+nian;
if((nian_temp%400==0)||((nian_temp%100!=0)&&(nian_temp%4==0))) //Judge whether it is a leap year
p_r=1;
else
p_r=0;
Conver_week(nian,yue,ri);
write_week(week);
Previous article:51 MCU Proteus simulation 320x240TFT color screen
Next article:Microcontroller breathing light program and waveform demonstration
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- What will happen if the servo motor inertia is insufficient?
- How to select parameters for servo motor inertia size
- The difference between the servo motor moment of inertia and the load moment of inertia
- How to calculate the inertia of servo motor and reducer
- [TI Live] Smart Building Special Session, Interpretation of Solutions and Core Components, Out-of-Stock Replacement
- Is it OK to use 74HC164 like this?
- Share an open source architecture of ethercat-based on XMC4800
- (Transfer) bluetooth abbreviation
- TI is now bringing you the skills to master complex automotive electronics design
- Smart Camera Structure Design--Update on Recent Amateur DIY
- First experience - unboxing
- WIFI 6 is coming, do you know about it?
- 【ST NUCLEO-H743ZI Review】(5)FREERTOS
- TMC5130 is used as a driver to drive the motor. Why does the motor hum when it is stationary?