Home
Implementing Real Time Clock and WAIT Mode
Contents
1. BOR KK k oko k kok kok kok k oko ko kok kok k ok kok ok kok k kok kok k kok k kok A k Kk kk Ck I kok kk kok k koe ke kok ke ke ke kk Name wait setup Parameters None Returns None Description This prepares the MCU to enter wait mode The application demo runs and after a preset period goes into wait mode Aside from the real time clock timer Bl the MCU can come out of wait mode by user intervention pressing one of the three user pushbuttons S2 S4 key input irq The key input irq to wake MCU must be set prior to wait mode so it can be used to wakeup the MCU This is disabled in the wakeup interrupt routine OKCKCK Ck AR kok kok k kok k kok kk Ck kok k kok kk kok Sk kk kk kk Sk kk k kk kk IA kok k kk X kk kk ke kk X kk ke ke ke e ke e kx void wait setup void save power ALL_LED_OFF all LEDs off disp ctrlw LCD CLEAR clear LCD enable key input irq asm FCLR I disable interrupts kupic 6 enable key input irg asm FSET I enable interrupts Switch to XCin and then turn Xin off before going to wait mode pred 1 unlock CMO cm07 1 Switch from Xin to XCin cm05 1 Stop Xin preco 0 lock CMO set our board mode to wait brd mode WAIT WARNING The WAIT instruction should never be called from within an interrupt handler Calling a WAIT instruction within an interrupt routine may cause unexpected clock or MCU behavior Ensure that the interrupt
2. AO Al A2 A3 A4 BO B1 B2 for user for for for for for for for for user user user user user user user user vector vector vector vector vector 29 Figure 3 Real time clock timer Timer B1 interrupt routine rtc int flowchart 25 26 REU05B0044 0101Z Sept 2004 Page 5 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode 3 5 WAIT Mode and Real time Clock In many applications the real time clock is required to operate under very low power conditions This can be accomplished by using a timer and the fc32 clock as the count source The fc32 clock allows very low power operation by allowing the MCU to operate in WAIT mode with all peripherals except those supplied with the fc32 clock to be disabled In the demo the real time clock timer B1 is used in Timer mode to generate an interrupt every second After the interrupt routine is serviced the M16C 26 goes into WAIT mode Every second the real time clock timer B1 interrupt occurs and triggers the M16C 26 out of WAIT mode the timer B1 interrupt routine is serviced and then the M16C 26 goes back to WAIT mode As a note an interrupt or a reset is required to bring the M16C 26 back from a WAIT mode and so ensure that interrupts are enabled and the interrupt routine is set 3 6 Entering WAIT Mode When the WAIT instruction is executed the BCLK stops and the M16C 26 go into WAIT mode If t
3. a license from the Japanese government and cannot be imported into a country other than the approved destination Any diversion or reexport contrary to the export control laws and regulations of Japan and or the country of destination is prohibited Please contact Renesas Technology Corporation for further details on these materials or the products contained therein
4. an external interrupt or Reset occurs In WAIT mode the clock that drives the MCU core logic BCLK is switched from the main clock to the sub clock circuit to lower power consumption The peripheral clocks can be stopped but not the sub clock oscillator divided by 32 fc32 to further lower power consumption Similar to STOP mode an interrupt or a reset is required to exit from WAIT mode A demo program for the MSV30262 SKP was developed to show the RTC WAIT implementation 3 0 Real Time Clock Setup and Implementation 3 1 Sub Clock Block and Hardware Figure 1 shows the block diagram of the M16C 26 clock generating circuit Figure 2 shows examples on how to wire the sub clock pins to a crystal or an oscillator The sub clock circuit generates two signals internally fc and fc32 fc 32 and can be used as a clock source for the different M16C 26 MCU peripherals A 32 768KHz crystal is connected to the sub clock pins on the MSV30262 Board REU05B0044 0101Z Sept 2004 Page 1 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode Oscillation stop detection circuit CM10 1 Write signal 1 r BCLK Main clock CM21 CM20 rd CMOS CM02 WAIT instruction RESE a 1 32 Software reset i 1 16 NMI DD Interrupt reguest level judgment output CM06 0 O CM17 CM16 11 CM06 0 CM17 CM16 10 CM06 0 CM17 CM16 01 CM06 0 CM0i Bit i at address 000616 PM
5. 2 NEC S AS APPLICATION NOTE M16C 26 Implementing Real Time Clock and WAIT Mode 1 0 Abstract The following article describes the implementation of a low power real time clock using the sub clock circuit with a 32 768 kHz crystal and Wait mode of the M16C 26 microcontroller MCU 2 0 Introduction This article shows how to use the M16C 26 MCU s WAIT mode and implement a real time clock function on the M16C 26 MCU using a 32 768KHz crystal on the sub clock circuit The Renesas M16C 26 is a 16 bit MCU based on the M16C 60 CPU core It has multiple peripherals such as 10 bit A D UARTS clock circuits etc There are three oscillator circuits in the M16C 26 which includes a main clock circuit a sub clock circuit and an on chip oscillator After a reset the MCU always starts running from the main clock which is usually used in normal operation The on chip oscillator is an internal oscillator which can be used in case the main clock stops The sub clock which needs to be enabled after reset is a low frequency clock that is useful for power reduction and as a low speed clock source for timers and other peripherals Using a 32 768KHz crystal in the sub clock circuit a one second timer can be generated and a real time clock RTC function is easily implemented The M16C 26 has two low power modes of operation STOP mode and WAIT mode When placed in STOP mode all oscillation circuits are stopped and the MCU remains in the STOP state until
6. CM1i Bit i at address 000716 PCLKi Bit i at address 025E16 CM2i Bit i at address 000C16 Details of divider Figure 1 M16C 26 Clock Circuit Block Diagram Microcomputer Built in feedback resistor Microcomputer Built in feedback resistor XCIN XCOUT XCIN XCOUT Open Externally derived clock von pm RN MR ge UR Vss Note Insert a damping resistor if required The resistance will vary depending on the oscillator and the oscillation drive capacity setting Use the value recommended by the maker of the oscillator Also if the oscillator manufacturer s data sheet specifies that a feedback resistor be added external to the chip insert a feedback resistor between XCIN and XCOUT following the instruction Figure 2 Connecting to Sub clock Pins REU05B0044 0101Z Sept 2004 Page 2 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode 3 2 Enabling the Sub clock Circuit As mentioned earlier the sub clock oscillation circuit is disabled after reset To be able to use the sub clock circuit it needs to be enabled The steps necessary to enable the sub clock circuit are listed below and followed by sample code listing used in the demo 1 Change Ports 8 6 XCin and 8 7 to inputs Start the 32Khz crystal sub clock pd8 7 0 setting GPIO to inputs XCin XCout pd8 6 0 2 Disable protection of clock control register prcO 1 Unlock CMO and CM1 3 Enable sub clock circu
7. D disp dataw disp dataw minl LCD disp dataw min2 LCD disp dataw disp dataw secl LCD disp dataw sec2 LCD KKK k k k kk kk k k kiki kk kk k k kaki k kc k kc k kc kkk k kkk kkk k ck k k k k k k k kk kkk kk k ke Name pto int Parameters None Returns None Description This is the RTC timer Timer Bl interrupt routine It is called every second ECKCKCk k ck k ck k kck k k kc k kk k k kiki k k k k kck kck kck A ck k kc k k kck kckckck ckck kck k Ck k kc kc kck ckck kck ck ck kckckckckckck koe k void rtc int void unsigned int i time calculation in military time mode if second gt 60 second 0 if minute gt 60 minute 0 hour if hour gt 23 hour 0 if brd_mode RUNNING in running mode disp_count increment display counter if disp_count gt 4 disp_count 1 on time decrement our on time if on time lt 0 time to go to wait mode brd mode GO TO WAIT if so let s prepare for it Make a heartbeat LED so it s visible that the program is running This is only for demo purposes For actual applications you can omit this routine x else in wait mode RED LED 0 Flash Red LED for i OxFF i gt 0 i add some delay RED LED 1 turn off Red LED REU05B0044 0101Z Sept 2004 Page 14 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Cl
8. and WAIT Mode Initalize brd_mode to RUNNING Y Initialize Sub clock amp Real Time Clock Timer rtc init Preset Clock set time Y Start Real time Clock Timer Display Current Time disp_time brd_mode RUNNING Prepare for brd_mode Y pois GO TO WAIT sub clock wait setup N Y y MCU in WAIT mode brd_mode WAIT NOTE 1 Functions called are in blue letters See rtc c for details 2 Board mode are shown in red letters Figure 4 RTC Wait Demo Program Flowchart REU05B0044 0101Z Sept 2004 Page 9 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode 4 2 Displaying Current Time on LCD Pressing any of the user pushbuttons S2 S3 or S4 will display the current time on the LCD and cause the sequential blinking of the three LED s for 10s 5 0 Conclusion Real time clock function is easily implemented in the M16C 26 MCU using any of its eight 16 bit timers Some real time clock function requires power conservation and can also be accomplished with the M16C 26 MCU by using WAIT mode 6 0 Reference Renesas Technology Corporation Semiconductor Home Page http www renesas com E mail Support support _apl renesas com Data Sheets e M16C 26 datasheets M30262eds pdf User s Manual e M16C 20 60 C Language Programming Manual 6020c pdf e M16C 20 60 Software Manual 6020s
9. he WAIT Peripheral Function Clock Stop bit CMO2 is set the peripheral device clocks are also stopped The oscillation circuits continue to operate in WAIT mode To minimize power requirements the sub clock can be selected as the system clock and the main clock oscillation circuit is stopped When the sub clock is selected as the system clock the Peripheral Function Clock Stop bit should not be set to 1 The basic steps to enter WAIT mode are shown below 1 Disable protection of the clock control registers prco 1 2 Switch the system clock to the sub clock cm07 1 3 Toreduce the power requirement stop the main clock cm05 1 4 Enable protection of the clock control registers prcO 0 5 Gall the WAIT instruction asm wait In the demo the wait setup function routine shown below makes the preparation for WAIT mode but does NOT execute the WAIT instruction The WAIT instruction is executed in the main loop List 1 For demo purposes aside from the real time clock timer interrupt another interrupt a key input interrupt was added to allow the M16C 26 to exit WAIT mode Pressing one of the three user pushbuttons S2 S3 or S4 on the MSV30262 Board generates a key input interrupt The key input interrupt routine wakeup int must also be defined similar to the real time clock timer B1 interrupt routine REU05B0044 0101Z Sept 2004 Page 6 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode
10. it cm04 1 Start the 32KHz crystal 4 Enable protection of clock control register prcO 0 Lock the System Clock Control Register 3 3 Setting up the Real Time Clock Timer Now that we have enabled the sub clock circuit we need to setup the second timer that will run the real time clock function As mentioned above the sub clock circuit generates fc and fc32 fc is the frequency of the crystal or oscillator connected to the sub clock pins On the other hand fc32 is fc divided by 32 On the MSV30262 Board a 32 768 KHz crystal is connected between Xcin and Xcout making fc equal to 32 768KHz The frequency fc32 then becomes 1 024KHz A sample code used in the demo on setting up a timer i e Timer B1 on the M16C 26 as the real time clock timer is shown below Configure Timer B1 RTC second timer tbilmr 0xc0 Timer mode fc32 32 768KHz 32 1024Hz tbl 1023 Set the counter to interrupt every second 1s 1024 0 1023 count Timer B1 is used in timer mode with fc32 as the clock source In Timer mode the timer will count down every fc32 from a preset value tb1 until it underflows When the timer underflows it will generate an interrupt request and reload the preset value into the count register It will then begin counting down again REU05B0044 0101Z Sept 2004 Page 3 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode To generate a 1 second timer Timer B1 count tb1 must be
11. k k kc k k ck kikki kaki ck k ck k kck ckck kck ck ck ck I Kok k void set_time void char set_flag 1 variable to go to next setting by pressing S4 1 set hour 2 set minute 3 run RTC initialize clock variables hour 0 minute 0 second 0 while set_flag lt 3 set Hour if set flag 1 if S_S2 incrementing variable everytime S2 is pressed while S_S2 wait for S2 to go back up if hour gt 23 max hour 12 12 PM hour 0 disp time 2 if S S3 1 decrement variable everytime S3 is pressed while S S3 wait for S3 to go back up if hour lt 0 min hour 0 0 AM hour 23 disp time 2 if S_S4 move to next setting minutes if S4 is pressed while S_S4 wait for S4 to go back up set_flag 2 set minutes set Minutes if set flag 2 display 0 Set Min display Set Minute if 5 s2 1 incrementing variable everytime S2 is pressed while S S2 wait for S2 to go back up if minute gt 59 max minute 59 minute 0 disp time 2 REU05B0044 0101Z Sept 2004 Page 12 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode if lS 93 1 decrement variable everytime 3 is pressed while S S3 wait for S3 to go back up if minute lt 0 min minute 0 minute 59 disp time 2 if S_S4 move to next setting run RTC if S4 is pressed while S_S4 wait f
12. ock and WAIT Mode 8 KK eR AR RRR I kkk kkk k kkk kkk A k k k k k k k k k k k k kk k k k k k k k k I k k k k k k k k k k k k ko ke Name wakeup_int Parameters None Returns None Description This interrupt routine will wake us up from wait mode due to user intervention by pressing any of the three user pushbuttons S2 S4 OK CKCk kk Ck kok Ck Ck kk Ck ko ke kk kk kok ke Kk CK KK kk kk KC Kk KC KC kk kok ke kk CK A ko kk ko ko ko k kok k k kokok k ek ke k eek void wakeup int void unsigned int i wakeup from wait mode turn Xin back on prc0 1 unlock CMO cm05 0 Enable Xin for i 0 i lt OxOF i delay routine to allow Xin oscillator to stabilize asm NOP cm06 0 No div need to be set again goes back to div by 8 in wait mode cm07 0 Switch from XCin to Xin prc0 0 lock CMO disable key input irq asm FCLR I disable interrupts kupic 0 disable key input irg asm FSET I enable interrupts switch brd mode to RUNNING brd mode RUNNING reset our demo run time every time we wake up on time RUN TIME J KCKCKCkCk kk kk kk kk kk kk kk A A kk Ck Ck kkk kkk kkk kkk kk kkk kkk kkk kkk kkk k kkk kkk ck k ck ck k kk kkk k Name wait setup Parameters None Returns None Description This prepares the MCU to enter wait mode The application demo runs and after a preset period goes into wait mode Aside from the real time clock
13. oftware pdf e Interrupt Handler App Note M16C26 Interrupt Handlers in C doc e MSV30262 SKP Users Manual Users Manual MSV30262 pdf REU05B0044 0101Z Sept 2004 Page 10 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode 7 0 Software Code The rtc c code used in the demo program is shown below The whole source code TM project for the RTC WAIT demo can be requested from the your Renesas representative KK RK KK KK KK k k k k A KK I IR I I I I kk kkk kk kk File Name rtc c Content Real Time Clock RTC functions for M16C that includes setting initial time displaying time RTC and wakeup interrupt routines ni Revision 1 1 2003 02 21 CKCKCk kk k ck k kck k k k Ck kk k k kiki ka ka kCk kc k k kc kck kck k k kc k kck k Ck k I I ck ck ck ck kck kckckckckck kk kx Kinclude NcommonNsfr262 h M16C 26 special function register definitions include common skp26 h MSV30262 SKP function definitions Finclude rtc h RTC function definitions interrupt routine used for rtc vectors modified in sect30 rtc inc pragma INTERRUPT rtc int tpragma INTERRUPT wakeup int define RUN TIME 10 preset demo run time before going into wait mode in seconds int hour minute second clock variables char on time demo run time and sleep time char brd mode Mode Running RTC displayed on LCD LEDs flashing sequentially Go to Wait Preparation f
14. or S4 to go back up set_flag 3 run RTC clock has been preset start RTC tbls 1 set on time on time RUN TIME Akk kkk kkk kkk k kk k k ki kikki kkk kc kk kiki ki kc k kc kckckckckck k k k k ck k kc kck ckck ck k k ck kckck ck ck k k k k k ke Name disp time Parameters LCD Line 1 display on Line 1 top 2 display on Line 2 bottom Returns none Description Displays time on LCD eR RK A I A k ck k kck kck kck A kc k k I I IAA I I I ko k void disp_time char LCD_Line unsigned char hrl LCD hr2 LCD minl_LCD min2_LCD secl LCD sec2_LCD characters for display unsigned int clk var get hour to display clk var unsigned int hour 10 hrl LCD num to char clk var hr2 LCD num to char unsigned int hour clk var 10 get minutes to display Clk var unsigned int minute 10 minl LCD num to char clk var min2 LCD num to char unsigned int minute clk var 10 get seconds to display Clk var unsigned int second 10 secl LCD num to char clk var Sec2 LCD num to char unsigned int second clk var 10 display time on LCD if LCD Line 1 disp ctrlw 0x80 top line of LCD first char else disp ctrlw 0xC0 bottom line of LCD first char REU05B0044 0101Z Sept 2004 Page 13 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode disp dataw hrl LCD disp dataw hr2 LC
15. or wait mode Wait No LCD and LEDs RTC Running Gonst char uuum to char l0 Q q1t 2 3 4 5S et vypv vgt Tgtys extern char disp count BK RK KK IK kk kk k k kk kk kk A I kckck ckck ck k kc k k kkk k kkk kkk k ck k k k k k ck kck kkk kkk ke Name init rto Parameters none Returns none Description Initialize the real time clock RTC CKCkCkckckckckck ckck Ck kck ck kckckckck ck ck ckck ckck ck ck k kck kck kckckck ckck ck k kck kc kck ck kckck kck ckckck kck ck k ckck ckck ck ck ck k ck ckckckckckok koe k void init rtc void Change XCin and XCout to inputs and start the 32Khz crystal sub clock pd8 7 0 setting GPIO to inputs XCin XCout pd8 6 0 pred 1 Unlock CMO and CM1 cm04 1 Start the 32KHz crystal prc0 0 Lock the System Clock Control Register REU05B0044 0101Z Sept 2004 Page 11 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode Configure Timer Bl RTC second timer tbimr 0xc0 Timer mode fc32 32 768KHz 32 1024Hz tbl 1023 Set the counter to interrupt every second 1s 1024 0 1023 count Akk kkk kkk Ck kk Ck Ck kk kk Sk kkk kk k k kk k kikki ki k kc kckckckckck k k ck k ck kiki k k k kikki ck k k k k ko ke Name set time Parameters none Returns none Description Presets clock and starts clock RTC ECKCkCk kckck kck kck k k k ck k kc k k k kikki k ck k I kck kck c
16. ponsibility for any damage liability or other loss rising from these inaccuracies or errors Please also pay attention to information published by Renesas Technology Corporation by various means including the Renesas Technology Corporation Semiconductor home page http www renesas com When using any or all of the information contained in these materials including product data diagrams charts programs and algorithms please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products Renesas Technology Corporation assumes no responsibility for any damage liability or other loss resulting from the information contained herein Renesas Technology Corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake Please contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor when considering the use of a product contained herein for any specific purposes such as apparatus or systems for transportation vehicular medical aerospace nuclear or undersea repeater use The prior written approval of Renesas Technology Corporation is necessary to reprint or reproduce in whole or in part these materials If these products or technologies are subject to the Japanese export control restrictions they must be exported under
17. set to count 1024 1 second x fc32 But since the counter goes to 0 setting tb1 to 1023 will generate a 1024 count The demo uses a 1 second timer but it can be setup as a 1 minute timer by setting tb1 to 61440 60 seconds x fc32 Once the timer is setup setting the start flag i e tb1s to 1 will start the timer running For the demo the timer was not started until the clock has been preset 3 4 The Real time Clock Interrupt Routine An interrupt is generated every second every time our timer underflows And so time must be calculated every time this interrupt routine is called A sample code that calculates time in military time format is shown below BRK RK kk k kk k k kA kk k k k k k Ck Ck Xi ck kck kckckck ckck kc k kc k kc k kiki k k ck k k kc k k k k ck ck ck kkk kkk k Name rto int Parameters None Returns None Description This is the RTC timer Timer B1 interrupt routine It is called every second oko oko k k KK kk kk ko Kk kk CK Kk kk KC Kk o oko k k KK Kk CK kok kok KC KK k KC Kk k ko kk k ke kk k kok k k ke kk eek e e ek f void rtc int void unsigned int i time calculation in military time mode if second gt 60 second 0 if minute gt 60 minute 0 hour if hour gt 23 hour 0 To tell the C compiler that the routine is an interrupt routine a pragma interrupt B irq_rtn must be defined and where irq_rtn is the routine to be processed
18. th appropriate measures such as i placement of substitutive auxiliary circuits ii use of nonflammable material or iii prevention against any malfunction or mishap Notes regarding these materials These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corporation product best suited to the customer s application they do not convey any license under any intellectual property rights or any other rights belonging to Renesas Technology Corporation or a third party Renesas Technology Corporation assumes no responsibility for any damage or infringement of any third party s rights originating in the use of any product data diagrams charts programs algorithms or circuit application examples contained in these materials All information contained in these materials including product data diagrams charts programs and algorithms represents information on products at the time of publication of these materials and are subject to change by Renesas Technology Corporation without notice due to product improvements or other reasons It is therefore recommended that customers contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor for the latest product information before purchasing a product listed herein The information described here may contain technical inaccuracies or typographical errors Renesas Technology Corporation assumes no res
19. that will allow the M16C 26 MCU to exit is enabled Otherwise the MCU will be stuck in WAIT mode while 1 infinite loop if brd mode RUNNING in RUNNING mode led display disp count display current count if temp sec second LCD is to be updated every second only display 0 RTC Time RTC Header disp time 2 current time temp sec second REU05B0044 0101Z Sept 2004 Page 7 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode else if brd_mode GO_TO_WAIT time to go wait mode wait setup yes let s prepare for wait mode else let s wait here brd mode WAIT asm WAIT in wait mode asm NOP 4 NOPs required after wait instruction asm NOP due to prefetch queue asm NOP asm NOP List 1 Executing a Wait Instruction 3 7 Exiting WAIT mode The MCU will exit WAIT mode when an interrupt or a reset occurs After exiting WAIT mode the MCU will enter the interrupt service routine for that interrupt After completion of the service routine the MCU will return to the instruction following the WAIT instruction In the demo there are two interrupts that will allow us to exit WAIT mode One is the RTC interrupt service routine which occurs every second The second is using a key input interrupt by pressing one of the three user pushbuttons The RTC interrupt is enabled during initialization and always remain enable The key inp
20. timer Bl the MCU can come out of wait mode by user intervention pressing one of the three user pushbuttons S2 S4 key input irg The key input irq to wake MCU must be set prior to wait mode so it can be used to wakeup the MCU This is disabled in the wakeup interrupt routine Kkkkk k k k kikaki k I kc kc kk kk kk kk I kckckckckckckckckckckckckckckckckckckckck ck ckck ckck ck ck ckckckck ck ck kk ke x void wait setup void save power REU05B0044 0101Z Sept 2004 Page 15 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock and WAIT Mode ALL_LED_OFF all LEDs off disp_ctrlw LCD_CLEAR clear LCD enable key input irq asm FCLR I disable interrupts kupic 6 enable key input irq asm FSET I enable interrupts Switch to XCin and then turn Xin off before going to wait mode prc0 1 unlock CMO cm07 1 Switch from Xin to XCin cm05 1 Stop Xin prc0 0 lock CMO set our board mode to wait brd mode WAIT REU05B0044 0101Z Sept 2004 Page 16 of 16 Keep safety first in your circuit designs Renesas Technology Corporation puts the maximum effort into making semiconductor products better and more reliable but there is always the possibility that trouble may occur with them Trouble with semiconductors may lead to personal injury fire or property damage Remember to give due consideration to safety when making your circuit designs wi
21. ut interrupt is enabled in the wait setup routine before the WAIT instruction is executed 4 0 The RTC and Wait Demo Program The RTC Wait demo program implemented all the topics discussed earlier For demo purposes the MSV30262 Board was used Like any other clock the current time must be preset before running the clock The clock is displayed on the LCD and the LED s are blinking sequentially After 10s the LCD and LED s are switched off to lower power consumption Every second as the real time clock timer B1 interrupt is generated the Red LED is blinked so that it s visible that a program is running Pressing one of the user pushbuttons S2 S3 or S4 will display the current time on the LCD and blink the LED s sequentially for 10s 4 1 Setting Initial Time After the RTC Wait program has been downloaded run the program Banners are displayed and then Set Hour will be displayed on the LCD Pressing S2 will increment the hour while pressing S3 will decrement the hour After the hour has been set press S4 to set the minutes Similar to setting the hour pressing S2 will increment minutes and pressing S3 decrements minutes After minutes have been set pressing S4 will start the clock Preset time is displayed on the LCD and the LED s will be blinking sequentially After 10s LCD will be blank and the heartbeat Red LED blinks every second REU05B0044 0101Z Sept 2004 Page 8 of 16 M16C 26 u 2 NI ESAS Implementing Real Time Clock
22. when the interrupt is generated A sample definition used in the demo and can be found in rtc c is shown below interrupt routine used for rtc vectors modified in sect30 rtc inc pragma INTERRUPT B rtc int To be able to jump to this rtc int routine the M16C 26 MCU needs to know its vector address The vector is set in an include file sect30 inc in the demo sect30 rtc inc Please see sample snippet below used in sect30 rtc inc on how to setup the interrupt vector for our real time clock timer REU05B0044 0101Z Sept 2004 Page 4 of 16 2 NEC S AS lword lword lword lword lword lword glb lword lword lword Start rtc int J dummy int dummy int dummy int dummy int dummy int dummy int rte int Ete int dummy in Ce CT dummy in Y Calculate Time brd_mode RUNNING Sequential LED display count l Decrement on_time counter on_time lt 0 zero brd mode GO TO WAIT M16C 26 Implementing Real Time Clock and WAIT Mode TIMER TIMER TIMER TIMER TIMER TIMER TIMER TIMER INTO N brd mode WAIT Demo Heartbeat Blink Red LED every second Return from Irq NOTE 1 Functions called are in blue letters See rtc c for details 2 Board mode are shown in red letters 3 Blinking Red LED is to show that a program is running
Download Pdf Manuals
Related Search
Related Contents
平成26年1月号 Manuale d`uso per l`utente Nastro trasportatore Nastri micra-c Outils de dépose de rotules de suspension arrière Lutter contre la déscolarisation advertencia - Appliance Factory Parts INSTALLATION MANUAL 取扱説明書 - A`PEXi RT-1000 - Rontan Osmium Data Recorder (DaRe) User Manual Copyright © All rights reserved.
Failed to retrieve file