Home

R32C/100 Series Application Note Real

image

Contents

1. Refer to http www renesas com for the latest and detailed information Renesas Electronics America Inc 2880 Scott Boulevard Santa Clara CA 95050 2554 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 651 700 Fax 44 1628 651 804 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel 49 211 65030 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd 7th Floor Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100083 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 204 205 AZIA Center No 1233 Lujiazui Ring Rd Pudong District Shanghai 200120 China Tel 86 21 5877 1818 Fax 86 21 6887 7858 7898 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2886 9318 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 80 Bendemeer Road Unit 06 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 03
2. 5 6 1 Main Processing Figure 5 2 shows the Main Processing Figure 5 2 Disable maskable interrupts flag 0 PLL clock setting SetPLLClock i Clock frequencies used in PLL mode are set Initialize port PO_O PO register P0_0 bit 1 Output high PDO register PDO_0 bit lt 1 Output port Timer AO initial setting timer_a0_init Sub clock oscillation setting subclock_set Wait mode preset processing before_wait_mode_set Initialize the fC CPSRF register divide by 32 divider CPSR bit lt 1 TABSR register Timer AO count starts TAOS bit lt 1 Enable maskable interrupts I flag 1 Power control processing power_control Main Processing RO1AN0859EJ0100 Rev 1 00 RENESAS Aug 24 2012 Real Time Clock Operation Using Timer A Page 11 of 21 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 2 Timer AO Initial Setting Figure 5 3 shows the Timer AO Initial Setting timer_a0_init Set the interrupt priority level for wake up Stop timer AO count Disable timer AO interrupt Set timer AO mode register Set timer AO register return Figure 5 3 Timer AO Initial Setting RIPL1 register 07h Level 7 RIPL2 register 07h Level 7 Bits RLVL2 to RLVLO 111b TABSR register TAOS bit lt 0 TAOIC register lt 00h Bits ILVL2 to ILVLO 000b Level 0 interrupt disabled IR bit 0 No interrupt requested TAOMR register COh Bit
3. LEN ESAS APPLICATION NOTE R32C 100 Series RO1AN0859EJ0100 Real Time Clock Operation Using Timer A Rev 1 00 Aug 24 2012 Abstract This document describes real time clock operation using the timer function in the R32C 100 Series MCU Products R32C 116 Group R32C 117 Group R32C 118 Group When using this application note with other Renesas MCUs careful evaluation is recommended after making modifications to comply with the alternate MCU RO1ANO0859EJ0100 Rev 1 00 ENESAS Page 1 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A Contents 1 A uo 3 2 Operation Confirmation Conditions rsiiiciiinniin arica ines 4 3 Reference Application Notes miii de 4 4 HardWare scr er E acer stakes E rE aseeuatene 5 4 1 Pin Used mision aie a a aa iaa ada aa a a eaa 5 5 A li odio 5 5 1 Operation OVERVIOW aisicc s cectsrcsnentestanscaddeiiesnaceccdaanenassnasceadeces aacdenvanacheneddchsdeadaceansaaduasedsagesedexsaandadeat 5 5 2 CONStANtS iii A A ake Baayen ea ee ae 6 5 3 Variables iia is ii a a a A AA A AA o ti 7 5 4 FUNCIONS ii tt a a dicte 7 5 5 FUNCION Specifications iii A a dida 8 5 6 Flowcharts crniiin a a a a ta 11 5 6 1 Main Processing cccccceceeceeseeneeeeeeceeeeeeeseeeeeeeeeseeeeaeeeeceeeaeeeeeeeeeaeeeeseeaaeeeeseecaeeeseeenaeeesteeaes 11 5 6 2 Timer AO Mial Sening sa a dde 12 5 6 3 Time Setien R T A de 13 5 6 4 Dae Setting mitra dd 14 5 6 5 Leap Day Determination ooconnnncccnn
4. disabled PRCR register PRCO bit lt 0 Disable to write to registers CMO and CM1 PRR register lt AAh Enable to write to the FMCR register FMCR register FEW bit lt 0 Normal operating mode PRR register lt 00h Disable to write to the FMCR register PRCR3 register PRC31 bit lt 1 Enable to write to VRCR register VRCR register MRS bit lt 1 Main regulator stopped PRCR3 register PRC31 bit lt 0 Disable to write to VRCR register 1 Perform this processing when using an embedded CPU rewrite program Figure 5 9 Wait Mode Preset Processing RO1ANO0859EJ0100 Rev 1 00 Aug 24 2012 2tENESAS Page 18 of 21 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 8 Power Control Processing Figure 5 10 shows the Power Control Processing Disable maskable interrupts flag lt 0 Disable the timer AO interrupt _ fe 000b Perform a dummy read priority level to 0 Enable maskable interrupts flag lt lt 1 Insert two NOP instructions Disable maskable interrupts flag lt 0 TAOIC register lt 07h adie bs Na Bits ILVL2 to ILVLO 111b Level 7 Set the processor interrupt priority level to 3 Set the wake up IPL setting RIPL1 register 03h registers Bits RLVL2 to RLVLO 011b Level 3 RIPL2 register lt 03h Bits RLVL2 to RLVLO 011b Level 3 Enable writing to register PRCR register PRCO bit 1 Enable to write to CMO register Set system clock CMO register control
5. or omissions from the information included herein 3 Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others 4 You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product 5 Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems and safety equipment etc Renesas Electronics pro
6. register 0 CMO02 bit lt 1 Peripheral clock source stopped in wait mode P PRCR register Disabl ting t t __ Disable writing to register PRCO bit lt 0 Disable to write to CMO register Enable maskable interrupts flag lt 1 Set port PO_0 to output low PO register P0_0 bit 0 Execute WAIT instruction Set port PO_0 to output high PO register P0_0 bit 1 return Figure 5 10 Power Control Processing RO1AN0859EJ0100 Rev 1 00 ENESAS Page 19 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 9 Timer AO Interrupt Handling Figure 5 11 shows the Timer AO Interrupt Handling _timer_a0 wake up Bits RLVL2 to RLVLO 111b Level 7 RIPL2 register lt 07h Bits RLVL2 to RLVLO 111b Level 7 Time setting time_set return Figure 5 11 Timer AO Interrupt Handling RO1ANO0859EJ0100 Rev 1 00 2tENESAS Page 20 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 6 Sample Code Sample code can be downloaded from the Renesas Electronics website 7 Reference Documents R32C 116 Group User s Manual Hardware Rev 1 10 R32C 117 Group User s Manual Hardware Rev 1 10 R32C 118 Group User s Manual Hardware Rev 1 10 The latest versions can be downloaded from the Renesas Electronics website Technical Update Technical News The latest information can be downloaded from the Renesas Electronics website C Compiler Manual R32C 100 Series
7. source is the main clock PRCR register PRC1 bit lt 0 Disable to write to PM2 register TCSPR register CST bit lt 0 Stop divider operation TCSPR register lt OAh Bits CNT3 to CNTO 1010b Main clock divided by 2n where n 10 TCSPR register CST bit 1 Start divider operation TA1MR register lt 80h Bits TMOD1 and TMODO 00b Timer mode Bits MR2 and MR1 00b No gate function Bits TCK1 and TCKO 10b f2n TA1 register lt 40000 1 50 ms PD8 register PD8_6 bit lt 0 Input port PD8_7 bit lt 0 Input port PUR2 register PU25 bit lt 0 P8_6 and P8_7 pull up resistor disabled PRCR register PRCO bit 1 Enable to write to CMO register CMO register CMO03 bit 1 XCIN XCOUT drive strength high CM04 bit 1 XCIN XCOUT oscillator CMO5 bit lt 0 Main clock oscillator enabled PRCR register PRCO bit lt 0 Disable to write to CMO register TABSR register TA1S bit lt 1 TABSR register TA1S bit 0 TA1IC register lt 00h Bits ILVL2 to ILVLO 000b Figure 5 7 Sub Clock Oscillation Setting 1 2 RO1ANO0859EJ0100 Rev 1 00 Aug 24 2012 2tENESAS Page 16 of 21 R32C 100 Series Real Time Clock Operation Using Timer A Set count source prescaler TCSPR register register CST bit lt 0 Stop divider operation Enable writing to register PRCR register PRC1 bit 1 Enable to write to PM2 register Set processor mode register 2 PM2 register PM26 bit lt 0 f2n clock source is peripheral
8. 00 Renesas Electronics Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics Korea Co Ltd 11F Samik Lavied or Bldg 720 2 Yeoksam Dong Kangnam Ku Seoul 135 080 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 O 2012 Renesas Electronics Corporation All rights reserved Colophon 2 2
9. 14 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 5 Leap Day Determination Figure 5 6 shows the Leap Day Determination leap_day_check Set 0 to the return value not a leap day Is the date February 29 Yes Can the year be divided by 4 Yes Set 1 leap day to the results Can the year be divided by 100 Yes Set 0 not a leap day to the results Can the year be divided by 400 Yes Set 1 leap day to the results return Figure 5 6 Leap Day Determination RO1AN0859EJ0100 Rev 1 00 RENESAS Aug 24 2012 Page 15 of 21 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 6 Sub Clock Oscillation Setting Figure 5 7 and Figure 5 8 show the sub clock oscillation setting subclock_set Stop timer A1 count Disable timer A1 interrupt Enable writing to register Set processor mode register 2 Disable writing to register Set count source prescaler register Set timer A1 mode register Set timer A1 register Set XCIN XCOUT pins Enable writing to register Set system clock control register O Disable writing to register Start timer A1 count Wait for sub clock oscillator to stabilize Stop timer A1 count Disable timer A1 interrupt TABSR register TA1S bit O TA11C register 00h Bits ILVL2 to ILVLO 000b PRCR register PRC1 bit lt 1 Enable to write to PM2 register PM2 register PM26 bit lt 1 f2n clock
10. C Compiler Package V 1 02 C Compiler User s Manual Rev 2 00 The latest version can be downloaded from the Renesas Electronics website Website and Support Renesas Electronics website http www renesas com Inquiries http www renesas com contact RO1AN0859EJ0100 Rev 1 00 2tENESAS Page 21 of 21 Aug 24 2012 Revision Histor SES y Real Time Clock Operation Using Timer A Rev Date Summary Aug 24 2012 Firstedition issued All trademarks and registered trademarks are the property of their respective owners General Precautions in the Handling of MPU MCU Products The following usage notes are applicable to all MPU MCU products from Renesas For detailed usage notes on the products covered by this manual refer to the relevant sections of the manual If the descriptions under General Precautions in the Handling of MPU MCU Products and in the body of the manual differ from each other the description in the body of the manual takes precedence 1 Handling of Unused Pins Handle unused pins in accord 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 LSI an associated shoot through current flows internally and malfunctions occur due to the false recognition of the pin state as an input signal beco
11. ates wait time for sub clock oscillation fXCIN 32 768 kHz Data for Data for Data for the number the number the day of of seconds of minutes the week Data for the year Figure 1 1 Relationship Between Date Day and Time Data Operating modes Low power Wait mode Low power Wait mode Low power mode mode mode WAIT Timer AO WAIT Timer AO instruction interrupt instruction interrupt generated generated Figure 1 2 Transition Between Operating Modes RO1AN0859EJ0100 Rev 1 00 ENESAS Page 3 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 2 Operation Confirmation Conditions The sample code accompanying this application note has been run and confirmed under the conditions below Table 2 1 Operation Confirmation Conditions Item Contents MCU used R5F64189DFD R32C 118 Group When in PLL mode e Main clock 16 MHz e PLL clock 100 MHz e Base clock 50 MHz e CPU clock 50 MHz e Peripheral bus clock 25 MHz e Peripheral function clock source 25 MHz Operating frequencies When in low power mode e Main clock is stopped e PLL clock is stopped e Base clock 32 768 kHz sub clock 32 768 kHz e CPU clock 32 768 kHz e Peripheral bus clock 16 384 kHz e Peripheral function clock source is stopped Operating voltage 5V Integrated development Renesas Electronics Corporation environment High performance Embedded Workshop Version 4 08 Renesas Ele
12. clock source Disable writing to register PRCR register PRC1 bit lt 0 Disable to write to PM2 register Figure 5 8 Sub Clock Oscillation Setting 2 2 RO1AN0859EJ0100 Rev 1 00 2tENESAS Page 17 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 7 Wait Mode Preset Processing Figure 5 9 shows Wait Mode Preset Processing before_wait_mode_set Enable writing to register Set low speed mode base clock Disable writing to register Enable writing to register Set base clock source Disable writing to register Enable writing to registers Set system clock control register O Stop PLL oscillator Disable writing to registers r See Note 1 Enable writing to register Set CPU rewrite mode Disable writing to register Enable writing to register Main regulator shut down Disable writing to register Note PRCR2 register PRC27 bit lt 1 Enable to write to the CM3 register CM3 register lt 00h Bits CM31 and CM30 00b fC PRCR2 register PRC27 bit lt 0 Disable to write to the CM3 register PRR register AAh Enable to write to the CCR register CCR register BCS bit lt 1 fC PRR register 00h Disable to write to the CCR register PRCR register PRCO bit lt 1 Enable to write to registers CMO and CM1 CMO register CMO3 bit lt 0 XCIN XCOUT drive strength low CMO5 bit 1 Main clock oscillator disabled CM1 register CM10 bit lt 1 PLL oscillator
13. ctronics Corporation R32C 100 Series C Compiler V 1 02 Release 01 Compile options SABIA D__STACKSIZE__ 0X300 D__ISTACKSIZE_ 0X300 DVECTOR_ADR 0x0FFFFFBDC c finfo dir CONFIGDIR Default setting is used in the integrated development environment Operating mode Single chip mode Sample code version Version 1 00 3 Reference Application Notes Application notes associated with this application note are listed below Refer to these application notes for additional information e R32C 100 Series Configuring PLL Mode REJO5B 1221 0100 R32C 100 Series Entering Low speed Mode REJ05B1222 0100 e R32C 100 Series Configuring Wait Mode REJ05B1223 0100 RO1AN0859EJ0100 Rev 1 00 2tENESAS Page 4 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 4 Hardware 4 1 Pin Used Table 4 1 lists the Pin Used and Its Function Table 4 1 Pin Used and Its Function Pin Name 1 0 Function PO_0 Output Confirm period for transition to wait mode 5 Software 5 1 Operation Overview Enter wait mode after setting the operating mode to low power mode With timer AO in timer mode use a timer AO interrupt with a 1 second period to exit wait mode The date day and time data are updated in the timer AO interrupt handler Leap day determination is performed when the month changes After the data is updated a WAIT instruction is used to enter wait mode again Settings Timer used Timer AO
14. ducts are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics 6 You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges 7 Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas E
15. e Mode used Timer mode e Timer AO count source fC32 e Interrupt used Timer AO interrupt e Gate function Not used Formula to calculate a 1 second counter 1000 ms 1 fC32 x TAO 1 1 32 768 kHz 32 x 1024 0 9765625 ms x 1024 1 Initial setting Set timer AO and low power mode as the initial setting 2 Timer AO count start Set the TAOS bit in the TABSR register to 1 to start the timer AO count After the timer AO count starts the real time clock starts counting from 00 00 00 Saturday January 1 2000 3 WAIT instruction execution Execute the WAIT instruction to enter wait mode 4 Timer AO interrupt generation When timer AO underflows the timer AO interrupt is generated and the MCU exits wait mode 5 Timer AO interrupt handling Date day and time data are updated in the timer AO interrupt handler However the values are stored in the variable in hexadecimal 6 Date day and time data initialization The count continues until 23 59 59 Saturday December 31 2099 and then resets to the initial date and time RO1AN0859EJ0100 Rev 1 00 ENESAS Page 5 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A Figure 5 1 shows an Example of Real Time Clock Operation SU pa 2 Count starts 4 Interrupt generated 5 Date day time data updated E 4 TAO register setting value TAOS bitin the 1 TABSR register 9 1 second 1 second IR bit inthe 1 TAOIC registe
16. eturned value None Remark Outline Time setting Header None Declaration void time_set void Description After setting the data for the seconds minutes hours date and day of the week the date setting function is called Argument None Returned value None Remark Outline Date setting Header None Declaration void date_set void Description The leap day determination function is called and depending on the result the date month and year data is set Argument None Returned value None Remark RO1ANO0859EJ0100 Rev 1 00 Aug 24 2012 ENESAS Page 8 of 21 R32C 100 Series Real Time Clock Operation Using Timer A leap_day_check Outline Leap day determination Header None Declaration unsigned char leap_day_check void Description e Leap day is determined e Years that can be evenly divided by 4 are determined to have the leap day February 29 However years that can be divided by 4 or divided by 100 but cannot be divided by 400 are determined to not have a leap day Argument None Returned value e Leap day 1 e Not a leap day 0 Remark subclock_set Outline Sub clock oscillation setting Header None Declaration void subclock_set void Description After setting both bits PD8_6 and PD8_7 in the PD8 register to O input mode and
17. lectronics products are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you 8 Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations 9 Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating
18. mber of days 1 to 31 Store data for day of the week Sunday Monday Tuesday Wednesday Thursday Friday Saturday unsigned char hour_cnt Store data for number of hours 00 to 23 time_set unsigned char min_cnt Store data for number of minutes 00 to 59 time_set unsigned char sec_cnt Store data for number of seconds 00 to 59 time_set unsigned char week cnt time_set date_set Table 5 3 const Variable Type Variable Name Contents Function Used Data table for the maximum number of days per month const unsigned char day_max_tbl 12 date_set 5 4 Functions Table 5 4 lists the Functions Table 5 4 Functions Function Name Outline timer_a0O_int Timer AO initial setting time_set Time setting date_set Date setting leap_day_check Leap day determination subclock_set Sub clock oscillation setting before_wait_mode_set Wait mode preset processing power_control Power control processing _timer_a0 Timer AO interrupt handling RO1AN0859EJ0100 Rev 1 00 ENESAS Page 7 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 5 5 Function Specifications The following tables list the sample code function specifications timer_a0_int Outline Timer AO initial setting Header None Declaration void timer_a0_init void Description Initial settings to use timer AO in timer mode Argument None R
19. me possible Unused pins should be handled as described under Handling of Unused Pins in the manual 2 Processing at Power on The state of the product is undefined at the moment when power is supplied The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied In a finished product where the reset signal is applied to the external reset pin the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited The reserved addresses are provided for the possible future expansion of functions Do not access these addresses the correct operation of LSI is not guaranteed if they are accessed 4 Clock Signals After applying a reset only release the reset line after the operating clock signal has become stable When switching the clock signal during program execution wait until the target clock signal has stabilized When the clock signal is generated with an external resonator or from an external oscillator during a reset ensure that the reset line is only released af
20. nnnccccnnnnnoncccnnnnnnrnnnnn naar ronca rra nn 15 5 6 6 Sub Clock Oscillation Sening otra tie titan aida paces 16 5 6 7 Wait Mode Preset Processing civic ta 18 5 6 8 Power Control Processing ooooionccccnnnnccccocnnnnnoncncnnnnnnnn cnn anno cnn nn anna rra nn 19 5 6 9 Timer AO Interrupt Handling eosin nicotina indeed 20 6 Sample Code AAA Ru A erreen EAEEREAAEEE EEEE EEE E EnEnenn EEn En EEEE EEE 21 7 Reference Doc ments ui 21 R01AN0859EJ0100 Rev 1 00 ENESAS Page 2 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 1 Specifications This document describes real time clock operation using timer AO in timer mode Enter wait mode after setting the operating mode to low power mode base clock source is the sub clock Use the timer AO interrupt to exit wait mode The date day and time data are updated in the timer AO interrupt handler The date day and time data start counting from 00 00 00 Saturday January 1 2000 The count continues until 23 59 59 Saturday December 31 2099 and then resets to the initial date and time The counter takes the leap day into account Table 1 1 lists the Peripheral Functions and Their Applications Figure 1 1 shows the Relationship Between Date Day and Time Data Figure 1 2 shows the Transition Between Operating Modes Table 1 1 Peripheral Functions and Their Applications Peripheral Function Application Timer AO in timer mode 1 second counter Timer A1 Gener
21. r 0 00 00 02 Date day and 00 00 00 Saturday 00 00 01 Saturday Saturday time data January 1 2000 January 1 2000 January 1 2000 Operating mode f 3 WAIT 3 WAIT 3 WAIT instruction instruction instruction Note 1 This bit becomes 0 when an interrupt request is accepted Figure 5 1 Example of Real Time Clock Operation 5 2 Constants Table 5 1 lists the Constants Used in the Sample Code Table 5 1 Constants Used in the Sample Code Constant Name Setting Value Contents 23 59 59 Saturday December 31 2099 3 WAIT instruction YEAR_MAX Data for the maximum number of years MONTH_MAX Data for the maximum number of months WEEK_MAX Data for the maximum number of weeks in a month HOUR_MAX Data for the maximum number of hours MIN_MAX Data for the maximum number of minutes SEC_MAX Data for the maximum number of seconds RO1AN0859EJ0100 Rev 1 00 RENESAS Aug 24 2012 Page 6 of 21 R32C 100 Series Real Time Clock Operation Using Timer A 5 3 Variables Table 5 2 lists the Global Variables and Table 5 3 lists the const Variable Table 5 2 Global Variables Variable Name Contents Function Used unsigned short year_cnt Store data for number of years 2000 to 2099 date_set leap_day_check unsigned char month_cnt Store data for number of months 1 to 12 date_set leap_day_check time_set date_set leap_day_check unsigned char day_cnt Store data for nu
22. s TMOD1 and TMODO 00b Timer mode Bits MR2 and MR1 00b No gate function Bits TCK1 and TCKO 11b fC32 TAO register lt 1024 1 1 second RO1ANO0859EJ0100 Rev 1 00 Aug 24 2012 2tENESAS Page 12 of 21 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 3 Time Setting Figure 5 4 shows the Time Setting Update data for number of seconds Is number of seconds more than 59 Yes Update data for number of minutes Set number of seconds to 00 Is number of minutes more than 59 Ye Update data for number of hours Set number of minutes to 00 Is number of hours more than 23 Yes Update data for date Update data for day of the week Set number of hours to 00 Date setting date_set Has 1 week elapsed Yes Set day of the week data to Sunday Figure 5 4 Time Setting RO1AN0859EJ0100 Rev 1 00 2tENESAS Page 13 of 21 Aug 24 2012 R32C 100 Series Real Time Clock Operation Using Timer A 5 6 4 Date Setting Figure 5 5 shows the Date Setting More than maximum number of days for this Yes Leap day determination leap_day_check Update data for month Set the date to the first Number of months is more than 12 Update data for year Set month data to January Number of years is more than 2099 Yes Set year data to 2000 Set day of week data to Saturday return Figure 5 5 Date Setting RO1AN0859EJ0100 Rev 1 00 2tENESAS Page
23. ter full stabilization of the clock signal Moreover when switching to a clock signal produced with an external resonator or by an external oscillator while program execution is in progress wait until the target clock signal is stable 5 Differences between Products Before changing from one product to another i e to one with a different part number confirm that the change will not lead to problems The characteristics of MPU MCU in the same group but having different part numbers may differ because of the differences in internal memory capacity and layout pattern When changing to products of different part numbers implement a system evaluation test for each of the products Notice 1 Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information 2 Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in
24. the PU25 bit in the PUR2 register to 0 pull up resistor unused set the CM04 bit in the CMO register to 1 XIN XCIN oscillator Argument None Returned value None Remark Set the oscillation stabilization time according to the manufacturer s recommendation before_wait_mode_set Outline Wait mode preset processing Header None Declaration void before_wait_mode_set void Description e Change the base clock source from the PLL clock to the sub clock and enter low speed mode Stop the main clock and PLL clock and transition from low speed mode to low power mode Argument None Returned value None Remark RO1ANO0859EJ0100 Rev 1 00 Aug 24 2012 ENESAS Page 9 of 21 R32C 100 Series Real Time Clock Operation Using Timer A power_control Outline Power control processing Header None Declaration void power_control void Set the interrupt priority level for wake up execute the WAIT instruction and enter wait mode Argument None Description Returned value None Remark _timer_a0 Outline Timer AO interrupt handling Header None Declaration void _timer_a0 void Description Call the timer_set function in the interrupt handler Argument None Returned value None Remark RO1ANO0859EJ0100 Rev 1 00 2tENESAS Page 10 of 21 Aug 24 2012 R32C 100 Series 5 6 Flowcharts
25. to military applications or use by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations 10 It is the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products 11 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics 12 Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics RENESAS SALES OFFICES Renesas Electronics Corporation http www renesas com

Download Pdf Manuals

image

Related Search

Related Contents

Fixed Assets User Manual  M3060 Indicator  Sony SLV-D370P User's Manual  Samsung MD32C Kasutusjuhend  Samsung SPF-105P Korisničko uputstvo  2015-0158 2015-02-10 groupe 1 herbicide mana ladder  保 証 ー  Inauguration réussie ! - Ville-saint-etienne-de-saint  Interact-TV Voice Command Robot Challenge Robotics User Manual  Benutzerhandbuch  

Copyright © All rights reserved.
Failed to retrieve file