I'd like to know which is the best way to measure current consumption on this demo board.
I need to verify standby current consumption.
Is there something similar?
Hello simonemassignan,
Thank you for reaching out to the Renesas Engineering Community!
There is also a measurement available for the current drawn by the evaluation MCU for your RL78/G22 Fast Prototyping Board. You can find the documentation at this link: rl78g22-fast-prototyping-board-users-manual. However, please note that the J11 header is not mounted on the board, and you need to cut the VDD pattern.I would also recommend placing a Shunts Short Circuit Cap/Header Pin Jumper Cap in the J11 slot in case you no longer need to measure the current.
I hope this helps!
Regards,JefIf this response, or one provided by another user, answers your question, please verify the answer. Thank you!Renesas Engineering Community Moderatorshttps://community.renesas.com/https://academy.renesas.com/en-support.renesas.com/.../
Is there an example for using Touch peripheral in a low power environment (similar to the example for RTK0EG0042S01001BJ) ?
Thanks
I'm glad to hear that my previous answer worked for you.
Regarding the touch peripheral of your board, you can refer to this link <rl78-family-using-qe-standalone-ver-develop-touch-applications-fpb-board> for the guide, and you can also download the sample code from this link: www.renesas.com/.../rl78-family-using-qe-standalone-ver-develop-touch-applications-fpb-board-rev100
Additionally, if you have an RL78/G22 Capacitive Touch Evaluation System CPU Board, you may try this application guide <rl78g22-capacitive-touch-low-power-guide-sms-mec-function>.
My targert device is the R7F102FFE2DFB RL78/G22 fast prototyping board and I'm interested in reproducing the example relative to the RL78/G22 Capacitive Touch Evaluation System since I'm focused on the touch usage while standby mode.
My source code is here.
The touch peripheral is working fine wihout the standby mode, so I supposed it is configured correctly.
In the following example I think MCU stucks in r_rssk_touch_stop_mode() routine in __stop() line.
I don't have a "touch event", so the g_qe_touch_flag is always 0.
__stop();if (1U == g_qe_touch_flag){break;}
Is there something that I'm missing?
(the touch peripheral is configured as "External trigger", I configured the timer to triggere the Snooze Mode Sequencer).
Thanks for your help.
int main (void);void qe_touch_main(void);
int main(void){ EI();
while(1) { qe_touch_main(); }
}
void qe_touch_main(void){ fsp_err_t err; BSP_ENABLE_INTERRUPT();
/* Initialize pins (function created by Smart Configurator) */ R_CTSU_PinSetInit();
/* Connection of unused pins for P123 and P124 */ /* The settings for the CMC register are described in the "mcu_clocks.c" file */ CSC |= 0x40U;
/* Open Touch middleware */ err = RM_TOUCH_Open(g_qe_touch_instance_config01.p_ctrl, g_qe_touch_instance_config01.p_cfg);
if (FSP_SUCCESS != err) { while (true) {} } MK2H |= 0x40U; /* Disable interrupt servicing of "write request interrupt for setting registers for each channel" */ MK3L |= 0x01U; /* Disable interrupt servicing of "measurement data transfer request interrupt" */ /* Select the event source for the CTSU in the ELCL */ ELSELR10 = 0x06U; /* ELCITL0 (32bit interval timer0) -> CTSU */
/* Initial offset tuning for config02 */ err = RM_TOUCH_ScanStart(g_qe_touch_instance_config01.p_ctrl); if (FSP_SUCCESS != err) { while (true) {} }
/* Clear the flag indicating that CTSU processing is complete. */ g_qe_touch_flag = 0U; /* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE;
R_Config_ITL000_Start();
while (true) { __stop(); while (0U == g_qe_touch_flag) {} /* Clear the flag indicating that CTSU processing is complete. */ g_qe_touch_flag = 0U; /* Get the scanned data */ err = RM_TOUCH_DataGet(g_qe_touch_instance_config01.p_ctrl, &button_status, NULL, NULL); if (FSP_SUCCESS == err) { R_Config_ITL000_Stop(); break; } } /* Main loop */ while (true) { r_rssk_touch_stop_mode(); r_rssk_touch_normal_mode(); }}
static void r_rssk_touch_stop_mode(void){ fsp_err_t err; /* TAU0 power off */ PER0 &= 0xFEU; /* Turn off LEDs */ LED3 = LED_OFF; /* Change interval time for STOP mode */ R_Config_ITL000_SetInterval(TOUCH_STOP_SCAN_INTERVAL); /* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; /* SMS setting */ err = RM_TOUCH_SmsSet(g_qe_touch_instance_config01.p_ctrl); if (FSP_SUCCESS != err) { while (true) {} } /* Scan start */ err = RM_TOUCH_ScanStart(g_qe_touch_instance_config01.p_ctrl); if (FSP_SUCCESS != err) { while (true) {} } /* Settings for returning from low power mode */ INTC_Start(); R_Config_ITL000_Start(); while (true) { /* Wait for CTSU to finish processing */ while (true) { __stop(); if (1U == g_qe_touch_flag) { break; } } /* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; /* Clear the flag indicating that CTSU processing is complete. */ g_qe_touch_flag = 0U; /* Get the scanned data */ err = RM_TOUCH_DataGet(g_qe_touch_instance_config01.p_ctrl, &button_status, NULL, NULL); if (FSP_SUCCESS == err) { if (0U != button_status) { /* Transition to NORMAL mode */ INTC_Stop(); R_Config_ITL000_Stop(); break; } } }}
static void r_rssk_touch_normal_mode(void){ fsp_err_t err; button_status = 0U; /* Reset normal mode timeout counter */ g_touch_timeout_count = 0U; /* TAU0 power on */ PER0 |= 0x01U; /* LED initialize for NOMAL mode */ LED3 = LED_ON; /* Change interval time for NORMAL mode */ R_Config_ITL000_SetInterval(TOUCH_NORMAL_SCAN_INTERVAL); /* Scan start */ err = RM_TOUCH_ScanStart(g_qe_touch_instance_config01.p_ctrl); if (FSP_SUCCESS != err) { while (true) {} }
/* Clear the flag indicating that CTSU processing is complete. */ g_qe_touch_flag = 0U; /* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; MK1H &= 0xFBU; /* Enable interrupt servicing of ITL */ R_Config_ITL000_Start(); /* for starting CTSU */
while (true) { /* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE; while (0U == g_qe_touch_flag) {} /* Clear the flag indicating that CTSU processing is complete. */ g_qe_touch_flag = 0U; /* Get the scanned data */ err = RM_TOUCH_DataGet(g_qe_touch_instance_config01.p_ctrl, &button_status, slider_position, wheel_position); if (FSP_SUCCESS == err) { /* If there is input to the touch sensor, clear the timeout counter. */ if(0U != button_status) { g_touch_timeout_count = 0U; /* Reset the timeout counter */ } } if (g_touch_timeout_count > TOUCH_TIMEOUT_COUNT) { /* Transition to STOP mode */ R_Config_ITL000_Stop(); MK1H |= 0x04U; /* Disable interrupt servicing of ITL */ break; } }}
How is the correct settings of these parameters?
Is the INTP5 pin the interrupt signal generated from the timer?
What is output port number for external trigger? It's the same pin of INTP5?
I think the problem is that my timer is not generating an interrupt signal, maybe some configuration is wrong.
Hi simonemassignan, sorry for late response.
I'm going into the problem, could you please share me, when you're facing issue with standby mode? do you use SNOOZE mode or STOP mode?
Does application runs after standby mode? and just touch peripheral doesn't work correctly during standby? Is it about overall functionality in standby or just with CTSU?
TouchProject.zip
I want to use the snooze mode sequencer as the example attached.
The application does not exit standby mode, I think the CTSU does not trigger the measure because the timer interrupt does not occurr.
This is where the firmware stucks, on stop() instruction.
This is the timer configuration.
After timer starts, ITLS00 register is set to 1 (see image below), so I think the compare match signal has been detected in channel 0.
Update on my work:
The following routine is called in main loop and it's working, just to demonstrate that timer overflows,
then CTSU start measurement and gives a callback when the measure end.
The problem is that I want to use the Snooze mode sequencer to reach the lowest power consumption
and it is not working for me.
********************************************************************
***************** WORKING *************************************
static void r_rssk_touch_stop_mode(void){ fsp_err_t err;
/* TAU0 power off */ PER0 &= 0xFEU;
/* Change interval time for STOP mode */ R_Config_ITL000_SetInterval(TOUCH_STOP_SCAN_INTERVAL);
/* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE;
/* Scan start */ err = RM_TOUCH_ScanStart(g_qe_touch_instance_config02.p_ctrl);
if (FSP_SUCCESS != err) { while (true) {} }
/* Settings for returning from low power mode */ R_Config_ITL000_Start();
while (true) { /* Wait for CTSU to finish processing */ while (true) { __stop();
if (1U == g_qe_touch_flag) { break; } }
/* Clear the flag indicating that CTSU processing is complete. */ g_qe_touch_flag = 0U;
/* Get the scanned data */ err = RM_TOUCH_DataGet(g_qe_touch_instance_config02.p_ctrl, &button_status, NULL, NULL); // I'm not yet interested on the data
R_Config_ITL000_Stop(); break;
}}
*********************************************************************************************
****************** NOT WORKING *******************************************************
/* Turn off LEDs */ LED3 = LED_OFF; r_rssk_touch_led_clear();
/* SMS setting */ err = RM_TOUCH_SmsSet(g_qe_touch_instance_config02.p_ctrl);
/* Settings for returning from low power mode */ INTC_Start(); R_Config_ITL000_Start();
if (1U == g_qe_touch_flag) { break; } } /* Clear interrupt flag */ ITLS0 &= (uint8_t)~_01_ITL_CHANNEL0_COUNT_MATCH_DETECTE;
/* Get the scanned data */ err = RM_TOUCH_DataGet(g_qe_touch_instance_config02.p_ctrl, &button_status, NULL, NULL); if (FSP_SUCCESS == err) { if (0U != button_status) { /* Transition to NORMAL mode */ INTC_Stop(); R_Config_ITL000_Stop(); break; // ----> reaches r_rssk_touch_normal_mode() routine } } }}
I'm not sure how the SMS works.
Thank you for updating, I'm working on your code, but I don't have hardware in hand.
I'll share you the possible solutions about that and explain those, I hope it will help. Thanks for your patience.
Assuming the problem is RM_TOUCH_SmsSet(g_qe_touch_instance_config02.p_ctrl),
I investigated on the register values.
These are the following while CPU is stuck in stop mode:
PER1 register: CTSUEN = 1, TML32EN = 1, SMSEN = 1
PPR1 register: CTSURES = 0, TML32RES = 0, SMSRES = 0,
SMSC register equals 0x85: SMSSTART = 1, SMSSTOP = 0, SMSTRGWAIT = 0, LONGWAIT = 0,
SMSTRGSEL3 = 0
SMSTRGSEL2 = 1
SMSTRGSEL1 = 0
SMSTRGSEL0 = 1
which means that the snooze mode sequencee activation trigger is the ELC output signal.
ELC, in my case, links a 32bit timer to the CTSU (ELSELR10 = 0x06U instruction).
Maybe the SMS is not triggered.....
SMSSTAT bit of SMS register equals 0, so the SMS is not operating.
As you might already know here’s a document for this:
https://www.renesas.com/us/en/document/apn/rl78-family-ctsu-module-software-integration-system
at the page 8, the procedure and concepts of using Snooze mode sequencer for touch unit is being demonstrated.
As document says we must configure 2 free GPIOs (Which are physically connected together) for trigger the ELC unit by CTSU. One GPIO which applies interrupt pulse for triggering ELC unit (after touch measurement is done), then ELC triggers SMS for judgement touch (the procedure and settings for simulating CPU in SMS is done by configurator)
That’s why we have to set external interrupt GPIO and specify external trigger PORT in configurator.
So, in configurator, output port number for external trigger and Bit number for external trigger must be specified as a normal output GPIO and must be connected physically in board to another input GPIO pin (configure this GPIO as OUTPUT and set it to 0 initially).
At the other hand, in configurator, the parameter “interrupt port number for external trigger” we have to specify the GPIO’s Port which we’ve connected external trigger pin to it and configure the INTPn interrupt like a simple external interrupt.
And as you already know, Snooze sequencer is acting like CPU, but it cannot handle massive instructions like that. (The instructions and memory managements are structed by configurator)
Also, The document implies, we cannot use this feature (auto judgment touch) for this number of capacitive touch in snooze mode, “This feature does not perform with the self-capacitance to 9 elements or more and the mutual capacitance to 8 elements or more.”
In this way, probably we won’t have any conflict with instructions, and after sensing a touch CTSU will be judged by SMS, and after sensing a touch SMS will generate an Interrupt (INTSMSE interrupt) then CPU will start normal operation and goes for getting touch data.
Also there's a specific document for implementing capacitive touch in snooze mode and low power consideration of it which you might find helpful.
https://www.renesas.com/us/en/document/apn/rl78g22-capacitive-touch-low-power-guide-sms-mec-function-rev110
Don't hesitate to ask further questions and tell me if it helped.
With best regards
Thanks a lot, I will try to apply your suggestion.
This means that the example that I took for RTK0EG0042S01001BJ board
is working in the RTK0EG0042S01001BJ board because P22 and P16 are connected together.
Since I'm using RTK7RLG220C00000BJ, this connection is not performed and this is why SMS is not triggered. Is it correct what I'm saying?
Yes. I think that's the problem. also consider, not using more than 9 touch channel.