/************************Initialize real-time clock********************************************/
void RTCInit(void)
{
YEAR = 2011; // Initial year
MONTH = 12; // Initial month
DOM = 6; // Initialization date
HOUR = 12;
MIN = 59;
SEC = 50;
//If the day of the week is used, initialize it correctly here: DOW = (value 0~6)
CIIR = 0x01; // Set the increment of the second value to generate an interrupt
CCR = 0x11; // Use independent oscillator to start RTC. (0x01, 0x10, 0x13 are not displayed)
}
void SendTimeRtc(void) // incorrect week number
{
U32 times;
U8 bak;
times = CTIME0; // Read complete clock register 0
/*
bak = (times>>24)&0x07; // Get the value of the week
Send_BUF[2] = bak/10+'0';
Send_BUF[3] = bak%10+'0';
// Send_BUF[4] = ':';
DataDisp(bak/10,2,0); //Display the day of the week Why is the day of the week incorrect?
Delay(4);
DataDisp(bak%10,3,0);
Delay(2);*/
bak = (times>>8)&0x3F; // Get the value of the score
Send_BUF[0] = bak/10+'0';
Send_BUF[1] = bak%10+'0';
Send_BUF[2] = ':';
DataDisp(bak/10,0,0); //Display minutes
Delay(4);
DataDisp(bak%10,1,1);
Delay(2);
bak = times&0x3F; // Get the value of seconds
Send_BUF[3] = bak/10+'0';
Send_BUF[4] = bak%10+'0';
Send_BUF[5] = ' ';
DataDisp(bak/10,2,0); //Display minutes
Delay(4);
DataDisp(bak%10,3,0);
Delay(2);
}
After working for a long time, the week was always wrong. Finally I figured it out, it turned out that the clock was not initialized in RTCInit().
Remember: If you want to get the day of the week, the day of the week register must be initialized, and then ARM will automatically calculate the day of the week data.
Previous article:ARM LPC210X GPIO operation related registers
Next article:ADC test program for LPC210X
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- 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)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Guess you like
- How do you know the capacity of the chip capacitors on the circuit board?
- Request information on the Antminer Z9mini mining machine control board
- DSP28335 performs FFT Fourier transform
- The most mainstream QI wireless charging schematic in 2022
- Thank you + family @【chat, laugh, make noise】
- Learning methods and experience of embedded systems
- I would like to know the functions of these two components, about switching power supply.
- Molex's compact Type-C connector saves valuable space in your design! Download and get a gift! Event starts now
- Knowledge about power amplifiers in RF chips
- Playing with Zynq Part 7 - Ubuntu and Windos file transfer tool WinSCP