1 System Hardware Design
1.1 Real-time Clock (RTC) Module
S3C2440A integrates an RTC module with calendar function, which can work with a backup battery when the system is turned off. RTC uses STRB/LDRB ARM operations to transmit 8-bit data of binary coded decimal (BCD) to the CPU. The data includes time information of year, month, day, week, hour, minute and second. In addition, the RTC module can also realize the alarm function. The RTC module uses a 32.768 kHz external crystal oscillator. The connection between the external crystal oscillator and the S3C2440A is shown in Figure 1. XTIrtc and XTOrtc are the 32.768 kHz crystal oscillator input and output of the RTC, respectively. The two 22 pF capacitors are the matching capacitors of the crystal oscillator. Only when the external capacitors are matched capacitors can the crystal oscillator frequency be guaranteed to be within the error range near the nominal frequency.
1.2 Universal Asynchronous Receiver Transmission (UART) Module
The UART of S3C2440A provides three independent asynchronous serial I/O ports, each of which can operate in interrupt mode or DMA mode. The UART can support
a rate of up to 115.2 kb·s-1 using the system clock. When operating the UART, the format of the data receiving frame and the transmitting frame are programmable, which contains 1 start bit, 5 to 8 data bits, 1 optional parity bit and 1 or 2 stop bits, which are all set by the linear controller (ULCONn). This article uses UART to change the time and set the alarm time. The serial communication connection diagram is shown in Figure 2.
[page]
1.3 LCD display module
The function of the LCD controller of S3C2440A is to transfer LCD image data from the video buffer in the system memory to the external LCD driver. The LCD control can be programmed to achieve different requirements of the screen, such as: the number of horizontal and vertical pixels, interface clock, refresh rate, etc. The connection circuit of S3C2440A and WXCAT35 LCD display module is shown in Figure 3.
The meaning of the LCD controller interface signals in the figure:
VFRAME: frame synchronization signal between LCD controller and LCD driver, which notifies LCD screen to display a new frame. LCD controller sends VFRAME signal after displaying a complete frame to start displaying a new frame.
VLINE: synchronization pulse signal between LCD controller and LCD driver, LCD driver uses it to display the content of horizontal shift register on LCD screen.
VCLK: pixel clock signal between LCD controller and LCD driver.
VM: AC signal used by LCD driver. LCD driver uses VM signal to change the polarity of row and column voltage used to turn on or off pixels, thereby controlling the display or extinguishing of pixels.
VD0~VD23: LCD pixel data output port.
2 Software Design
2.1 Read and Write RTC Operation
S3C2440 integrates RTC module internally. Its internal registers BCDSEC, BCDMIN, BCDHOUR, BCDDAY, BCDDATE, BCDMON and BCDYEAR store the current seconds, minutes, hours, weekdays, days, months and years respectively. The values representing time are all BCD codes. The contents of these registers are readable and writable. When performing read and write operations, the 0th bit of the RTC control register RTCCON must be set to 1. The program to implement the read and write functions is as follows.
[page]
2.2 Change time and set alarm time
Use the UART of S3C2440A to change the real-time clock and set the alarm time on the PC. The communication protocol is: when 0xaa is sent from the PC, the year, month, day, week, hour, minute and second are written to the real-time clock data register respectively. When S3C2440A receives the data, it sends 0xaa to confirm and calls the previous write operation function to change the real-time clock; when 0xbb is sent from the PC, the preset alarm time ALMYEAR (year), ALMMON (month), ALMDATE (day), ALMHOUR (hour), ALMMIN (minute) and ALMSEC (second) are written to the alarm time data register respectively. When S3C2440A receives the data, it sends 0xbb to confirm and calls the alarm time setting function to set the alarm time. By setting the alarm control register RTCALM, the alarm can be realized. The program flow chart is shown in Figure 4.
2.3 Lunar calendar display design
The real-time clock module of S3C2440 does not provide the time information of the lunar calendar, so the Gregorian calendar is converted to the lunar calendar to realize the display of the lunar calendar. The algorithm for converting the Gregorian calendar to the lunar calendar is: first, establish the lunar calendar data corresponding to the Gregorian calendar year and store it in an array, and then realize the conversion between the Gregorian calendar and the lunar calendar by looking up the table.
Establish the lunar calendar data corresponding to the Gregorian calendar year, and use 3 bytes to represent each year.
The high 4 bits of the first byte of the lunar calendar data corresponding to the Gregorian calendar year represent the leap year month of the lunar calendar, and the low 4 bits represent the size of the first to fourth months of the lunar calendar. The specific meanings are shown in Table 1. The second byte represents the size of the fifth to twelfth months of the lunar calendar, and the specific meanings are shown in Table 2. The highest bit of the third byte represents the size of the thirteenth month of the lunar calendar, the seventh and sixth bits represent the Gregorian calendar month of the Spring Festival, and the low 5 bits represent the Gregorian calendar date of the Spring Festival. The specific meanings are shown in Table 3.
[page]
Taking 2010 as an example, there is no leap month in the lunar calendar. The first and third months of the lunar calendar are long months, and the second and fourth months are short months, so the first byte is 00001010 (i.e. 0x0A); the fifth, eighth, tenth and twelfth months of the lunar calendar are long months, and the sixth, seventh, ninth and eleventh months are short months, so the second byte is 10010101 (i.e. 0x95); since there is no leap month in the lunar calendar of 2010, there is no 13th month, so the seventh bit of the third byte is 0, and the Spring Festival of 2010 is on February 14th of the Gregorian calendar, so the sixth to the 0th bits of the third byte are 1001110, that is, the third byte is 0x4E.The algorithm block diagram of converting the Gregorian calendar to the lunar calendar is shown in Figure 5.
2.4 Display of real-time clock
The read real-time clock is displayed on the LCD screen by calling the character display function. This article converts the real-time clock characters to be displayed into fonts, puts the obtained fonts in an array, reads the real-time clock register, and calls the character display function to display numbers and Chinese characters, thereby displaying the real-time clock on the LCD screen. The final display effect is shown in Figure 6.
3 Conclusion
A real-time clock display circuit with lunar calendar based on Samsung's ARM9 processor S3C2440 and LCD WXCAT35 is designed. In order to realize the real-time display of RTC, the RTC time beat interrupt provided in S3C2440A is used to make it interrupt once per second, read the time each time, and refresh the real-time clock. In addition, after modifying the RTC through UART, the external key interrupt is used to update the real-time clock, thereby completing the modification of the time. The design enables the real-time clock chip without lunar calendar to display the lunar calendar through software, which enhances the application range of the chip and provides convenience for working environments that require lunar calendar clock as a reference.
Previous article:Access control monitoring system software design based on ARM9 and Linux
Next article:Remote Video Monitoring System Based on ARM and CDMA
Recommended ReadingLatest update time:2024-11-17 00:30
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- About the CRC enable problem of stm32f207
- Small base stations, a powerful tool to solve the pain points of 5G networks
- How to automate the test of electromagnetic relays? (Experience sharing - Part 1)
- MSP430F5529 Unified Clock System UCS
- 3020 laser engraving machine modification size
- What are some IC chip replacement techniques you have in PCB circuit design?
- MSP430FR6043 Ultrasonic Sensing Evaluation Module
- Video Album: ST MEMS Sensor Online Seminar (Continuously Updated)
- Openmv4 for sale
- 【NXP Rapid IoT Review】- Unboxing and Demo Experience