Hi,
We were using internal RTC interrupt to wake up from StandBy mode. We required a low-power device, to achieve this we changed the oscillator clock from MAIN CLOCK to SUBSYSTEM CLOCK and then switched to HALT State.But What we observed is that RTC ALARM Interrupt generation time increased to 2 twice of average time consumed.
[ Example In Main Clock Alarm generated for every 1min means it take 2min to generate Alarm in Subsystem clock.We are using Renesas rl78/g13 MCU, e2 studio, and CC-RL compiler. Version - v1.11.00
Hi Shashank,
I was able to reproduce this and yes, the clock doubled. Even the 1Hz output of the RTC became 0.5Hz. I'm using RL78/G14 and GCC for RL78 compiler. I checked the hardware user's manual and found this:
You need to perform either of the two examples before shifting to HALT or STOP mode. I tried both and they both work. You can't just be sure with the timing of example 1 so I recommend example 2. Here's my code:
/*********************************************************************************************************************** * DISCLAIMER * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. * No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all * applicable laws, including copyright laws. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED * OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY * LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR * ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability * of this software. By using this software, you agree to the additional terms and conditions found by accessing the * following link: * http://www.renesas.com/disclaimer * * Copyright (C) 2011, 2021 Renesas Electronics Corporation. All rights reserved. ***********************************************************************************************************************/ /*********************************************************************************************************************** * File Name : r_main.c * Version : CodeGenerator for RL78/G14 V2.05.06.02 [08 Nov 2021] * Device(s) : R5F104ML * Tool-Chain : GCCRL78 * Description : This file implements main function. * Creation Date: 23/09/2022 ***********************************************************************************************************************/ /*********************************************************************************************************************** Includes ***********************************************************************************************************************/ #include "r_cg_macrodriver.h" #include "r_cg_cgc.h" #include "r_cg_rtc.h" /* Start user code for include. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ #include "r_cg_userdefine.h" /*********************************************************************************************************************** Global variables and functions ***********************************************************************************************************************/ /* Start user code for global. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ void R_MAIN_UserInit(void); /*********************************************************************************************************************** * Function Name: main * Description : This function implements main function. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void main(void) { R_MAIN_UserInit(); /* Start user code. Do not edit comment generated here */ PM5_bit.no2 = 0; R_RTC_Set_RTC1HZOn(); R_RTC_Set_AlarmOn(); R_RTC_Start(); while (1U) { /* Example 1 */ /* uint16_t i; for (i=0;i<65535;i++) { NOP(); } */ /* or */ /* Example 2 */ RWAIT = 1; while (RWST != 1) {} RWAIT = 0; while (RWST != 0) {} HALT(); } /* End user code. Do not edit comment generated here */ } /*********************************************************************************************************************** * Function Name: R_MAIN_UserInit * Description : This function adds user code before implementing main function. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_MAIN_UserInit(void) { /* Start user code. Do not edit comment generated here */ EI(); /* End user code. Do not edit comment generated here */ } /* Start user code for adding. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
I used the code generator to configure the RTC. I set it to alarm after 1 minute and then toggle a GPIO pin.
JBIf this response, or one provided by another user, answers your question, please verify the answer. Thank you!Renesas Engineering Community Moderatorhttps://community.renesas.com/https://academy.renesas.com/https://en-support.renesas.com/knowledgeBase/
Hi JB,
Thank you for your quick reply.
We tried your suggestion but didn't work when we changed the oscillator clock to the subsystem clock.I am adding coding snippets where we are changing the oscillator clock.
void MAIN_to_SUBSYSTEM(void) { // RTCMK = 1U; /* disable INTRTC interrupt */ OSMC = _80_CGC_SUBINHALT_OFF | _10_CGC_RTC_CLK_FIL; /* Set fSUB */ XTSTOP = 0U; ITIF = 0U; /* clear INTIT interrupt flag */ ITMK = 0U; /* enable INTIT interrupt */ g_int_cnt = 0U; /* int cnt clear */ ITMC = 0x8FFFU; do { NOP(); } while (4U >= g_int_cnt); ITMC = _0000_IT_OPERATION_DISABLE; /* Set fCLK */ CSS = 1U; ITIF = 0U; /* clear INTIT interrupt flag */ g_int_cnt = 0U; /* int cnt clear */ ITMC = 0x8001U; do { if (1U == g_int_cnt) { R_MAIN_ERROR(); } else { /* Do Nothing */ } } while (0 == CLS); ITMK = 1U; /* desable INTIT interrupt */ ITMC = _0000_IT_OPERATION_DISABLE; /* Set fIH */ HIOSTOP = 1U; // RTCIF = 0U; /* clear INTRTC interrupt flag */ // RTCMK = 0U; /* enable INTRTC interrupt */ P1_bit.no7= ~(P1_bit.no7); RWAIT = 1; while (RWST != 1) {} RWAIT = 0; while (RWST != 0) {} HALT(); P1_bit.no7= ~(P1_bit.no7); return; }
Hi JB,Can you help me with this issue?
We have been stuck on this issue for a long time.
Guide us to solve this issue/problem.
Thank You
.
The code before shifting to HALT mode that I've given you will certainly work. However, I think your problem here is your code in changing clocks. I'm seeing lines in your code that are related to the 12-bit Interval Timer. Why would you configure the registers related to the 12-bit IT? If you want to reduce operating current, instead of HALT, why not try the STOP mode? I guess in this case, you don't need to switch the main clock anymore.