background image

RX230 Group, RX231 Group 

Initial Settings and Usage Procedure of RTC Battery Backup Function 

R01AN4831EJ0100  Rev.1.00 

 

Page 7 of 23 

Aug.20.19 

 

1.2  Operating Environment 

Table 1.2, Operating Environment, shows the environment in which the operation of the sample program was 
confirmed. 

Table 1.2   Operating Environment 

Item 

Description 

MCU used 

R5F52318ADFP (RX231 Group) 

Board used 

Renesas Starter Kit for RX231 (product number: R0K505231S000BE) 

CPU operating frequency 

Refer to 2.3, Clock Settings. 

Integrated development 
environment 

Renesas Electronics 
e

2

 studio Version 7.5.0 

C compiler 

Renesas Electronics 
C/C++ Compiler Package for RX Family V.3.01.00 

Emulator 

E1 

Endian order 

Little-endian 

 

The sample program uses FIT modules to control battery backup function and programming of the flash 
memory. LCD display software uses the sample code provided with the RSK board, and the drivers of other 
functions than battery backup and flash programming are generated using Smart Configurator (SC). Note 
that in the sample program, R_Config_RTC_Create function call, which is generated for RTC battery backup 
operation by SC, r_cg_hardware_setup.c file is deleted.  

void R_Systeminit(void)
{
    /* Enable writing to registers related to operating modes, LPC, CGC and 
software reset */
    SYSTEM.PRCR.WORD = 0xA50FU;

    /* Enable writing to MPC pin function control registers */
    MPC.PWPR.BIT.B0WI = 0U;
    MPC.PWPR.BIT.PFSWE = 1U;

    /* Initialize clocks settings */
    R_CGC_Create();

    /* Set peripheral settings */
    R_Config_PORT_Create();
    R_Config_CMT0_Create();
    R_Config_LVD1_Create();
    R_Config_SCI8_Create();
    R_Config_RTC_Create();

← Deleted.

 

Figure 1.3   Modification of r_cg_hardware_setup.c 

Summary of Contents for RX230

Page 1: ...nded after making modifications to comply with the alternate MCU Related Application Notes Application notes related to this application note are listed below Consult them in conjunction with this application note Firmware Integration Technology User s Manual R01AN1833 RX Family Adding Firmware Integration Technology Modules to Projects R01AN1723 RX Family Adding Firmware Integration Technology Mo...

Page 2: ...tion 12 3 4 Option Setting Memory Settings 12 3 5 Constants 13 3 6 Variables 13 3 7 Functions Used 13 3 8 Function Specifications 14 3 8 1 main 14 3 8 2 flash_Init 14 3 8 3 display_time 14 3 8 4 display_info 15 3 8 5 backup_time 15 4 Flowcharts 16 4 1 main Function main 16 4 2 Erase Data Flash Function flash_Init 17 4 3 Display Time Information Function display_time 17 4 4 Battery Status and Switc...

Page 3: ...RX230 Group RX231 Group Initial Settings and Usage Procedure of RTC Battery Backup Function R01AN4831EJ0100 Rev 1 00 Page 3 of 23 Aug 20 19 Revision History 23 ...

Page 4: ...supply of the RTC sub clock switches automatically to the VBATT power supply The LCD that displays the time information goes blank 3 VBATT voltage drop detection VCC off VBATT on During battery backup RTC operation continues Dung this period if battery voltage drops below 1 8V RTC operation is not guaranteed and VBATRLVDETF bit set to 1 By checking this bit we can confirm whether VBAT voltage drop...

Page 5: ...initial state Vcc On active Vbatt On No generated Enable Operating Yes No Yes Enable 2 Vcc On Off Vbatt On On switch to battery Generated No Operating Turn off Saved No Enable 3 Vcc Off Vbatt On battery active On hold No Operating No if VBATT below 1 8V No Saved No Enable inputted 4 Vcc Off On switch to VCC Vbatt On Released No Operating Turn on Saved No Yes if VBATT below 1 8V detected Enable 5 V...

Page 6: ...ttery backup power supply voltage drop 1 8 V detected VCC on Initialize LCD Display RTC information on LCD VBATRLVDETF 2 Initialize sub clock oscillator RTC setting and switch count Clear VBATRLVDETF bit to 0 No Yes Check whether battery voltage has dropped below 1 8V Vdet1 interrupt Save data to flash if VCC drops below 3 1V Return VBATT interrupt Display voltage drop alert If VBATT voltage drops...

Page 7: ...ogram uses FIT modules to control battery backup function and programming of the flash memory LCD display software uses the sample code provided with the RSK board and the drivers of other functions than battery backup and flash programming are generated using Smart Configurator SC Note that in the sample program R_Config_RTC_Create function call which is generated for RTC battery backup operation...

Page 8: ...SP RX Family Board Support Package Module Using Firmware Integration Technology R01AN1685 r_bsp_rx 5 20 Device driver RX Family Battery Backup Function Module Firmware Integration Technology R01AN2796 r_vbatt_rx 1 03 RX Family Flash Module Using Firmware Integration Technology R01AN2184 r_flash_rx 4 00 Table 1 4 Sample Code Type Application Note Title Document No Revision Sample Code RX231 Group R...

Page 9: ...nector USB serial port Power LED Power connector 5 V E1 connector User LED USB Host USB Function port User switches E1 emulator Potentiometer Expansion board interface application header Touch keys Touch slider Figure 2 1 RSKRX231 2 2 Pins Used The MCU pins used are listed below Table 2 1 Related Pins Pin Name I O Description PC7 Output SCI8 transmit PC5 Output SCI8 clock P31 Input RTC input captu...

Page 10: ...heral clock D PCLKD 27 MHz PLL 2 Flash interface clock FCLK 27 MHz PLL 2 2 4 LCD Panel The LCD panel Pmod specification included with the RSK is used 2 5 Hardware Modifications To confirm the operation of the sample program modifications were made to the RSK to enable battery backup operation 2 5 1 VBATT Connection The RX231 RSK board is provided with jumper J10 to allow confirming operation of th...

Page 11: ...1 RSK board is designed SW1 for IRQ1 RTCIC1 input and it is set to pull up by VCC It is therefore necessary to make the following modifications 1 Remove resistor R271 2 Connect IRQ1 to VBATT battery through an external switch 3 When the switch is turned on VBATT is connected to IRQ1 For reference when performing modifications see Figure 2 4 RTCIC1 Circuit Detail Excerpted from RSKRX231 CPU Board S...

Page 12: ...ealtime clock Config_CMT0 Compare match timer module Supplies control functionality and drivers for the compare match timer Config_LVD1 Voltage detection circuit module Supplies control functionality and drivers for the voltage detection circuit Config_PORT Port module Supplies control functionality and drivers for the port Config_SCI8 SPI clock synchronous communication module Supplies control fu...

Page 13: ...nctions Function Name Outline main System main function display_time Display time information display_info Display battery and switch states backup_time Write time information to the data flash flash_Init Erase the data flash and perform blank checking The functions used in the sample code of each FIT SC modules are listed below Table 3 7 SC Module Functions Function Name Outline Contained in File...

Page 14: ...R_Config_RTC_Set_CalendarCounterValue R_Config_RTC_Start R_VBATT_Open R_VBATT_GetStatus Arguments Return value 3 8 2 flash_Init Table 3 9 flash_Init Function Item Details Function Name flash_Init Outline Erases data flash to store RTC information Declaration void flash_Init void Description Erases block 0 of data flash and performs blank checking Functions called R_FLASH_Erase R_FLASH_BlankCheck A...

Page 15: ...info uint8_t Description Displays the battery and switch states on the LCD Functions called R_LCD_Display Arguments Display start line count Return value 3 8 5 backup_time Table 3 12 backup_time Function Item Details Function Name backup_time Outline Save time information function Declaration void backup_time void Description Reads time information from the RTC and stores it in the data flash Func...

Page 16: ...ation display_time PRD interrupt initial settings Initialize variable Erase data flash flash_Init Display RTC time information display_time Display battery state and switch push count display_info Check battery state R_VBATT_GetStatus Check switch push count Yes No Yes No Start voltage detection circuit R_Config_LVD1_Start Initialize VBATT R_VBATT_Open Is there a save history 55AAh at flash memory...

Page 17: ...ase Data Flash Function 4 3 Display Time Information Function display_time Figure 4 3 is a flowchart of the function for displaying time information on the LCD display_time RETURN line_num 7 Read RTC capture value R_Config_RTC_Get_Calendar TimeCaptureValue1 Display on LCD R_LCD_Display Convert year month and day to ASCII Yes No Read RTC information R_Config_RTC_Get_CalendarCounterValue Convert hou...

Page 18: ...witch Push Count Display Function display_time Figure 4 4 is a flowchart of the function for displaying the battery status and switch push count on the LCD display_info RETURN batty_err 1 Display on LCD R_LCD_Display Yes No Convert switch push count to ASCII Set empty field in array Set ALERT in array Figure 4 4 Battery Status and Switch Push Count Display Function ...

Page 19: ...tion for saving time information to the data flash Vdet1 interrupt processing Figure 4 5 Save Time Information Function backup_time RETURN Write to data flash R_FLASH_Write Set year month day hour minute and second data in array Set battery state and switch push count in array Set flash write history in array Read RTC information R_Config_RTC_Get_CalendarCounterValue Verify data written to flash S...

Page 20: ... count RTC input capture time Flash save data Figure 5 1 Display Setting 5 1 1 Execution During Battery Backup Operation 1 After VCC and VBATT are turned on the LCD displays the time counting every second The battery state and the number of times SW2 has been pressed are also displayed RX231 Bat backup Real time 19 04 30 23 59 40 BAT SW 12 Capture time Previous time Figure 5 2 Display During Norma...

Page 21: ...ert is displayed Figure 5 4 Alert Display When VBATT Drops 5 1 2 Battery Backup Operation Disruption If VCC is turned on after VCC and VBATT were cut off the time information and SW2 push count saved at the previous time VCC dropped is displayed on the LCD screen Figure 5 5 Display when VCC Recovery after VCC and VBATT Disruption RX231 Bat backup Real time 19 05 01 00 10 30 BAT ALERT SW 00 Capture...

Page 22: ...ring MCU is powered by VCC Moreover during VCC powers all functions multiplexed can be used However after power was switched to VBATT only RTC input capture function can continue to operate This means if these pins are set to other functions that RTC input capture during VCC power after switching to VBATT those function cannot continue to operate and pin states become Hi Z Therefore in case batter...

Page 23: ...231 Group Initial Settings and Usage Procedure of RTC Battery Backup Function R01AN4831EJ0100 Rev 1 00 Page 23 of 23 Aug 20 19 Revision History Rev Date Description Page Summary 1 00 Aug 20 2019 First edition issued ...

Page 24: ...put signal during power off state as described in your product documentation 4 Handling of unused pins Handle unused pins in accordance with the directions given under handling of unused pins in the manual The input pins of CMOS products are generally in the high impedance state In operation with an unused pin in the open circuit state extra electromagnetic noise is induced in the vicinity of the ...

Page 25: ...ons failure or accident arising out of the use of Renesas Electronics products outside of such specified ranges 7 Although Renesas Electronics endeavors to improve the quality and reliability of Renesas Electronics products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Unless designated as a hi...

Reviews: