SPRACV5 February   2021 MSP430FR2433

 

  1.   Application Brief
  2.   Trademarks

Application Brief

In a number of applications such as metering, building automation, and remote sensing, it is important to be able to keep track of the real time for monitoring or coordination purposes. Often additional information about system state also needs to be stored through a power loss to the main system. The MSP430FR2433 microcontroller (MCU) can be used as a low cost solution for this problem by making use of the internal real time clock (RTC) counter module and internal ferroelectric random access memory (FRAM) as backup memory. By using the UART, the host can set the initial time in POSIX format, and it can interrogate the MSP430™ MCU over the UART to provide the current time in the same format. Additionally, the host can write to and read from 16 bytes of backup memory, within the MSP430FR2433 device. This allows for data retrieval even after a total system power loss. To get started, download project files and a code example demonstrating this functionality

Note: This example can be used with any MSP430 LaunchPad™ Development Kit with the required MCU peripherals. For migrating pinouts and peripherals, see the device-specific data sheet.

Implementation

The RTC Counter module is used as an external RTC to provide the current real time in POSIX format. The host can set the initial time and then read the current time through a UART interface. The 16-MHz SMCLK is used as the clock source for the RTC Counter and UART modules. Alternatively, an external 32768-Hz crystal can be used as the clock source if the crystal selection resistors are changed on the MSP430FR2433 LaunchPad Development Kit and the __ENABLE_XT1__ symbol is added to the compiler settings in the CCS project. The RTC Counter module sourced from the 32768-Hz crystal is configured to generate an interrupt once per second. The interrupt service routine updates the timestamp value stored in FRAM. The host must set the initial timestamp the very first time after programming using the WRITE TIME command. From then on, the MSP430 device will keep updating the timestamp value. The current timestamp value will be retained through a reset or power loss.

Note: This example requires resistors R2/R3 to be populated and R4/R5 to be removed to use the LF XTAL for the MSP430FR2433 as shown in Figure 1-1. For the exact specifications to enable the LF XTAL, check your LP documentation.

The MSP430FR2433 LaunchPad Development Kit (Figure 1-1) was used for testing this solution, but it can be used on any MSP430 MCU with the proper peripheral support and code migration. The LaunchPad's eZFET back-channel UART interface can be connected to a PC terminal program or GUI Composer at 9600 baud for evaluating and further testing.

GUID-FE993C28-A64F-4D14-A89F-9CF8BD0CEE9C-low.png Figure 1-1 MSP-EXP430FR2433 LaunchPad Development Kit

The firmware implements the following UART communication protocol:

COMMAND D0 D1 D2 D3

For the READ commands, the data bytes are requested as a response from the MSP430 MCU. The command byte for each response is included for identifying the data more easily. For the WRITE commands, the data bytes are sent to the MSP430 MCU to be processed. Both the timestamp and alarm data are sent LSB first. The timestamp data should be interpreted as D3D2D1D0h, and the lapse time data as D0h.

RTC_READ_TIME Command

00h

D0

D1

D2

D3

RTC_WRITE_TIME Command

01h D0 D1 D2 D3

ALARM_WRITE_TIME Command

02h D0

BACKUP_MEM_ADDRESS Command

03h D0

BACKUP_MEM_READ_DATA Command

04h D0

BACKUP_MEM_WRITE_DATA

05h D0

Performance

In this solution both timestamp and the backup memory are stored in FRAM and are nonvolatile, so they will be retained even through a total power loss. By default, the FRAM is write-protected. The FRAM is only unprotected when a timestamp and must be stored, and then it is protected again after the RTC Counter module in the device updates the real time once per second. The host can request the current real time by sending the RTC_READ_TIME command to the MSP430 MCU. If the real time must be updated, the host can send the RTC_WRITE_TIME command along with the current real time. Also sending the ALARM_WRITE_TIME command to the MSP430 MCU sets the Alarm and starts the count down and glows the LED once the time reduced to 0. For storing the backup memory in FRAM, First set the address using BACKUP_MEM_ADDRESS command and the write the 8 bit data using the BACKUP_MEM_WRITE_DATA command and to read the data, first set the address using BACKUP_MEM_ADDRESS command and send BACKUP_MEM_READ_DATA command which will read the data from designated address.

For the standalone demo, a PC terminal program (for example, Docklight, Tera Term, and so forth) can be used as the host. An example demonstrating all of the commands and data including reading the initial RTC time, setting a new time and reading the time to confirm it was updated is shown in Figure 1-2. Observe that the RTC_WRITE_TIME command was sent to the MSP430 MCU at 10:06:30 and set to 78563412h. 7 second later at 10:06:30, the RTC_READ_TIME command was sent, and the reply shows the current timestamp value was incremented by 7 second to 78563419h. Notice that an unsupported command of 95h was sent but was correctly ignored by the MSP430 MCU at 10:08:22.

GUID-A0005404-9F60-4C66-8226-269630AA14FA-low.png Figure 1-2 Memory backup with a Timestamp Standalone Demo

For the GUI demo, the GUI can be used as the host as shown in Figure 1-3. The RTC can be read by clicking the CURRENT TIMESTAMP button in the first section. A new timestamp can be set by entering an 8-digit POSIX timestamp in the text box and pressing Enter. The Alarm can be set using the slider control (maximum of 255 seconds). Once the Alarm is set, ELAPSED TIME field shows the countdown time and once this value reduced to 0, the ALARM LED on the GUI turns ON also glows LED (P1.0) on The MSP430FR2433 LaunchPad Development Kit. Note that the GUI demo code can be used in standalone mode by deleting the __ENABLE_GUI__ symbol in the compiler settings in the CCS project, recompiling the code and programming the device.

GUID-E7863A21-E9DE-4259-A6D9-72B9AACE65AE-low.png Figure 1-3 Memory backup with a Timestamp GUI Demo

Limitations of this implementation include that no temperature compensation or calibration to adjust for small ppm errors of the 32768-Hz crystal is implemented. This means that the RTC could drift slightly over time, so it would be recommended for the host to periodically re-sync the RTC by sending the WRITE TIME command (for example, once per day).

To Get Started

  1. Watch the training video “Real-Time Clock with Backup Memory using a Housekeeping MCU” to learn how to use the GUI to set a timestamp and then find out when a power failure occurred.
  2. Order a MSP430FR2433 LaunchPad Development Kit to evaluate the Voltage Monitor with a Timestamp example GUI and code.
  3. Download and test the Real-Time Clock with Backup Memory example GUI to easily configure and view the timestamps and thresholds.
  4. Evaluate the Real-Time Clock with Backup Memory example code using the MSP430FR2433 LaunchPad Development Kit.
Table 1-1 Device Recommendations
Part Number Key Features
MSP430FR2433 16KB FRAM, 4KB SRAM, 10-bit ADC, UART/SPI/I2C, Timer
MSP430FR2422 8KB FRAM, 2KB SRAM, 10-bit ADC, UART/SPI/I2C, Timer