This example code starts by setting up the RTC and TIMER0, then switches the microcontroller (MCU) to Power-down mode. TIMER0 will count the pulses on PB5 until the RTC wakes up the MCU, at which point the counting will stop and the number of pulses will be printed.
You can download the sample code at https://www.nuvoton.com/resource-download.jsp?tp_GUID=EC012024091006190337