Low power and low cost real-time clock based on MSP430F11X

Publisher:buzzedyLatest update time:2012-02-17 Source: ti.com.cn Keywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Preface

Real-time clocks (RTCs) can be applied to a variety of fields - from clocks to time-stamping events, and even to generating events. In the fields of communication engineering, power automation, industrial control, and other fields with a high degree of automation, many devices are unattended in most cases, and it is hoped that the time of the failure and related information can be recorded for specific analysis. There are many dedicated RTC devices on the market, which often have poor flexibility and low system integration. The MSP430F11X series of microcontrollers have the advantages of low cost, low current consumption, flexible and simple use, and good scalability, making it an ideal substitute for dedicated RTC devices in some special occasions.

This system uses TI's ultra-low power 16-bit microprocessor - MSP430F111, which has extremely low power consumption, strong anti-interference ability and high cost performance. The whole system can work for a long time with only two ordinary batteries (working voltage is 3V), without other power supply, which greatly broadens the scope of application.

System working principle and implementation

The main difficulty of this system is how to generate a stable system clock. All MSP430 devices contain both a digitally controlled RC oscillator and a crystal oscillator. Generally, the RC oscillator is used for the CPU clock, while the crystal oscillator is used for peripheral devices. In real-time clock applications, the crystal oscillator can be used as the clock source for the timer/counter used as the time base. Therefore, there is no instability problem that is common to RC oscillators.

The process of making an MSP430 into an RTC is simple, including a timer/counter to provide 1s interrupts and a small CPU subroutine to count the interrupts. Between interrupts, the CPU can be in sleep mode or perform other functions. The actual operation process should also include an interface subroutine for the host processor to extract time from the MSP430 RTC, as well as other system functions such as battery monitoring, system monitoring, communication interfaces, etc.

The MSP430F111 is a very simple and inexpensive device in the MSP430F11X series, with 14 general-purpose I/O pins, 2 16-bit timers, 2KB flash memory, 128B RAM and a basic clock module.

Clock Generation
The RTC uses the LFXT1 oscillator with a 32768Hz crystal in LF mode to generate the clock. The output of the LFXT1 oscillator is used to provide ACLK, which is then used as the clock source for the timer/counter, which in turn is used as the time base for the RTC.

The DCO generates the CPU clock MCLK. In fact, the CPU and peripheral device timer/counter run asynchronously. As long as the CPU can calculate each interrupt from the timer/counter before the next interrupt arrives, the accuracy of the RTC will not be affected.

Timer/Counter Selection
MSP430F111 contains 2 timers: watchdog timer and timer A. Timer A is used as a time base and is designed to count continuously and provide an interrupt every 1s. Since timer A uses ACLK as its clock source, and the operating crystal frequency of ACLK is precisely 32768Hz, timer A can simply count to 32768 and then start to roll over to 0, giving an interrupt every time it counts to 32768. The CPU can simply calculate the interrupt from timer A.

External Interfaces
Because various RTC interfaces are now easily available, most of them can be applied to MSP430, such as I2C, parallel interface, UART and serial interface. TI has ready-made program code modules to implement the interface with MSP430 and are easy to integrate. In this way, building a complete RTC based on MSP430 becomes a simple matter of choosing an interface.

Circuit Description
Figure 1 is the circuit diagram of the RTC, the only external component required here is a 32768Hz crystal.


Figure 1 RTC circuit diagram [page]

Current Consumption
The typical current consumption of the MSP430F111 in normal working mode (3V, 1MHz) is 330μA. The typical current consumption in low power mode (sleep mode) is 1.5μA (3V). The device wakes up from low power mode in less than 6μs, and the clock program can be executed in about 130μs. Due to the extremely low current consumption and the extremely short time in active mode, using the 'F111 as an RTC consumes only very little current, so its battery life is the longest.

The accuracy of the crystal and
the accuracy of the selected RTC depends only on the accuracy of the crystal selected for the crystal oscillator. We can buy the appropriate crystal based on the accuracy we expect.

The accuracy of a crystal is primarily affected by two factors: the frequency tolerance of the crystal and the specified load capacitance.

The tolerance of the crystal is very obvious. The smaller the tolerance of the crystal frequency, the more accurate the RTC will be.

The specified load capacitance of the crystal also affects the accuracy of the RTC. The load capacitance of the crystal is the sum of the capacitance required by the crystal, not the sum of the capacitance provided by the crystal. The crystal needs appropriate load capacitance to start oscillating at the specified frequency. The 32768Hz oscillator used in all MSP430 devices has integrated a load with a rated capacitance of 12pF. This provides a full 12pF load for the crystal, which means that in order to obtain the best RTC accuracy, the connected 32768Hz crystal must be specified to use a 12pF load capacitance.

In applications where tighter RTC tolerance is required, a more adjustable capacitor can be used that is adjusted during manufacturing.

Higher grade ceramic (i.e. NP0 type) capacitors and polyester film capacitors are better suited for timing applications because they have lower dielectric losses and better temperature coefficients than general purpose ceramic capacitors.

The scalable
MSP430F111 is an extremely low power, low cost microcontroller that is ideal for real-time clock devices. One of the main advantages of using the MSP430 as an RTC is its scalability compared to dedicated RTC devices. All MSP430x11x devices include a 16-bit RISC CPU, 16-bit watchdog timer, 16-bit Timer A (with 3 capture/compare registers and analog comparator), a minimum of 128B of RAM, a minimum of 2Kb of ROM, and a minimum of 14 pins of general purpose I/O ports. It is clear that the MSP430 can provide flexibility that other dedicated RTCs cannot match.

In addition, the Timer A module can provide slope A/D conversion, PWM output and UART working speed up to 115200 baud rate. The watchdog timer can also be used as a simple timer, and the general I/O ports and all peripherals have expandable interrupt capabilities. [page]

Software Design


The RTC application code is quite simple and includes an initialization subroutine, a main loop, a clock counting subroutine to calculate hours, minutes and seconds, and an interrupt service subroutine to handle the 1s interrupt from timer A.

The initialization routine initializes the different parts of the MSP430. The watchdog timer is disabled and the Timer A module is configured to count continuously from 0 to 32768 and give an interrupt each time it reaches 32768. The basic clock module is also set.

The main loop is an infinite loop. Whenever timer A issues an interrupt, it calls the clock counting subroutine, otherwise it puts the CPU into sleep mode. When the CPU is asleep, timer A continues to count.

The Timer A Interrupt Service Routine (ISR) processes the Status Register (SR) bits that are pushed onto the stack before entering the ISR. This allows the CPU to be in active mode instead of sleep mode just after returning from the ISR. The ISR also clears the Timer A interrupt flag.

The clock counting subroutine counts each timer A interrupt as 1 second.

Source Program

START MOV #Stack,SP
CALL #Setup ; Initialization settings
Mainloop BIS #LPM3,SR ; CPU enters low power mode 3
CALL #Clock ; Enter the clock calculation after interrupt processing
JMP Mainloop ; Enter power saving mode again
Clock SETC ; Set the carry bit
DADC.b SECOND ; Second plus 1
CMP.b #060d,SECOND ; Determine whether it is full 1 minute
JLO Clockend ; If dissatisfied, jump out
CLR.b SECOND ; Clear the seconds counter
DADC.b MINUTE ; Points plus 1
CMP.b #60d,MINUTE ; Determine whether it is full 1 hour
JLO Clockend ; If dissatisfied, jump out
CLR.b MINUTE ; Clear the minute counter
DADC.b HOUR ; hour plus 1
CMP.b #024d,HOUR ; Determine whether it is full 24 hours
JLO Clockend ; If dissatisfied, jump out
CLR.b HOUR ; Clear the hour counter
Clockend RET
; Set up modules and control registers
Setup MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable watchdog
MOV.b #08Ch,&BCSCTL1 ; Set up the oscillator and clock control registers
MOV.b #000h,&BCSCTL2 ; Select DCOCLK as the MCLK clock source
SetupTA MOV #0106h,&TACTL ; Set timer A control register
MOV #CCRE0,&CCTL0 ; Interrupt enable
MOV #8000h,&CCR0 ; Set the time interval
BIS #10h,&TACTL ; Start TA and start count-up mode
ClearRAM MOV.b #00h,SECOND ; Clear the seconds, minutes and hours counters
MOV.b #00h,MINUTE
MOV.b #00h,HOUR
EINT ; Interrupt enable
RET
Timer A Interrupt Service Routine (ISR)
TAint BIC #SCG0+CPUOFF,0 (SP) ; Processing status register (SR) bits
BIC #TAIFG,&TACTL ; Clear the timer A interrupt flag
RETI

Conclusion

The whole system has a simple structure, strong scalability, and low cost (one piece of 'F111 is only more than 10 yuan), and the system is in low power consumption mode most of the time. Therefore, this system is suitable for implementing a real-time clock in unattended situations and harsh environments without considering power supply issues.

Reference
1 Hu Dake MSP430 Series FLASH Ultra-Low Power 16-bit Microcontroller Beijing University of Aeronautics and Astronautics Press 2001

Keywords:MSP430 Reference address:Low power and low cost real-time clock based on MSP430F11X

Previous article:Design of MSP430 Mixed Voltage and Logic System
Next article:D/A conversion based on MSP430 Timer_B

Recommended ReadingLatest update time:2024-11-16 17:34

MSP430 interrupt priority, open and close, interrupt nesting
The priority order from high to low is: PORT2_VECTOR  (1  *  2u)  PORT1_VECTOR  (4  *  2u)  TIMERA1_VECTOR  (5  *  2u)  TIMERA0_VECTOR  (6  *  2u)  ADC_VECTOR  (7  *  2u)  USART0TX_VECTOR  (8  *  2u)  USART0RX_VECTOR  (9  *  2u)  WDT_VECTOR  (10  *  2u)  COMPARATORA_VECTOR  (11  *  2u)  TIMERB1_VEC
[Microcontroller]
Wireless temperature and humidity real-time monitoring system based on MSP430F149
introduction With the rapid development of Internet of Things technology and the establishment of various big data centers, various data monitoring systems, especially wireless data monitoring systems, have emerged. Among them, the wireless temperature and humidity monitoring system is a very representative wireless m
[Microcontroller]
Wireless temperature and humidity real-time monitoring system based on MSP430F149
MSP430F5529 (II) Watchdog settings
The watchdog timer (Watchdog Timer (WDT_A)) is actually a special timer, which can be used as a watchdog or a timer. The so-called watchdog function refers to the ability to monitor whether the program runs away due to some interference or errors. The principle is that when the time of the failure meets the specified
[Microcontroller]
MSP430F5529 (II) Watchdog settings
MSP430G2553 WDT NMI interrupt example
Set the RST/NMI pin to NMI mode, turn on the P1.0 LED in the main program, and turn off the LED in the NMI interrupt  . The phenomenon is that when the RST button is pressed, the LED goes out and never lights up again (unless the power is turned on again). #include "MSP430G2553.h" void   main( void  )  {    WDTCTL
[Microcontroller]
MSP430 ADC12 sampling analysis
         The AD part mainly configures the clock, reference source, sampling channel, sampling mode, storage and sample-and-hold of the ADC12 module.      I'll take it one part at a time.      The first is the clock of the ADC12 module. This is the clock when the module is running. It is different from the sampling ti
[Microcontroller]
MSP430 ADC12 sampling analysis
MSP430-IO Port Introduction
The ports of MSP430 are P1, P2, P3, P4, P5, P6, S and COM (different models contain different ports, such as MSP430X11X series only have P1 and P2 ports, while MSP430X4XX series contains all the above ports), which can be used directly for input/output. There are no special input/output instructions in the MSP430 syste
[Microcontroller]
msp430 DMA controller
1. Only F15/16x has DMA (Direct Memory Access is a data exchange mode that accesses data directly from memory without going through the CPU.) to ensure high-speed data transmission. (For example, the DMA controller can directly transfer the contents of the ADC conversion memory to RAM) to process data, not tasks. 2. F
[Microcontroller]
Differences and similarities between Timer_B and Timer_A of MSP430 microcontroller
Common features of Timer_B and Timer_A 1 4 working modes 2 with optional, configurable counter input clock source 3. Multiple independent configurable capture/compare modules 4 There are multiple configurable output units with 8 output modes 5 DMA Enable 6 The interrupt function is
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号