Download Print this page
Renesas R8C/11 Application Note
Hide thumbs Also See for R8C/11:

Advertisement

Quick Links

R8C/11, R8C/13 Group
Adjusting the Frequency of the High-speed On-chip Oscillator
Using a Commercial Frequency
1.
Abstract
This application note describes a program that adjusts the oscillation frequency of the high-speed on-chip
oscillator using a commercial frequency (50/60 Hz).
2.
Introduction
The explanation of this issue is applied to the following condition:
Microcomputer
RAM size, ROM size
This program can also be used when operating other microcomputers within the R8C/Tiny, provided they
have the same SFR (Special Function Registers) as the R8C/11 microcomputers. However, some functions
may have been modified.
Refer to the Hardware Manual for details. Use functions covered in this Application Note only after careful
evaluation.
3.
Contents
3.1 Outline of the High-speed On-chip Oscillator
The R8C/11 group of microcomputers incorporate approximately an 8 MHz high-speed on-chip oscillator. The
operating oscillation frequency of the on-chip oscillator tends to fluctuate due to external factors such as the
operating temperature and power supply voltage. The oscillation frequency can be adjusted by setting up the
HR1 register appropriately.
The relationship between the set value of the HR1 register and the oscillation period of the high-speed
on-chip oscillator is shown below. However, because the amount of delay in each bit is not even, be sure to
change each bit to adjust. Also make sure bit 7 is set to "0".
Oscillation period of the high-speed on-chip oscillator
This application note explains how to adjust the oscillation frequency of the high-speed on-chip oscillator
using a commercial frequency (50/60 Hz).
REJ05B0471-0100Z/Rev.1.00
: R8C/11, R8C/13 Group
:1 Kbytes, 16 Kbytes
b5
=td(HRoffset)+(b6+
2
July 2004
APPLICATION NOTE
b4
b3
b2
+
+
+
4
8
16
b1
b0
+
+
) × td(HR)
32
64
Page 1 of 21

Advertisement

loading

Summary of Contents for Renesas R8C/11

  • Page 1 :1 Kbytes, 16 Kbytes This program can also be used when operating other microcomputers within the R8C/Tiny, provided they have the same SFR (Special Function Registers) as the R8C/11 microcomputers. However, some functions may have been modified. Refer to the Hardware Manual for details. Use functions covered in this Application Note only after careful evaluation.
  • Page 2 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 3.2 Outline of the Program The following shows how to adjust the oscillation frequency of the high-speed on-chip oscillator using a commercial frequency. Measure the commercial frequency with timer C that uses the high-speed on-chip oscillator as its count source.
  • Page 3 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency Adjust the high-speed on-chip oscillator during initial operating time and save the set value in the flash ROM. Make sure the address to which it is saved does not match that of a block where the program is located. A sample program memory map is shown in Figure 2.
  • Page 4: Function Table

    R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency Function Table and Flow Chart 4.1 Function Table Declaring void main(void) Outline Main Argument Argument Type Meaning None Return Value Return Value Type Value Meaning...
  • Page 5 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency Declaring void flash_close_ew1_mode(void) Outline EW1 mode exit Argument Argument Type Meaning None Return Value Return Value Type Value Meaning None Function Description Disables CPU rewrite mode (EW1 mode)
  • Page 6 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.2 Flow Chart 4.2.1 Main Function main() Set clock source for CPU clock and peripheral function clock to high-speed on-chip oscillator Set the ports and set the initial value of the HR1 SFR initialize register.
  • Page 7 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.2.2 SFR Initialize Function sfr_init() Initialize port P3 Initialize HR1 register return REJ05B0471-0100Z/Rev.1.00 July 2004 Page 7 of 21...
  • Page 8 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.2.3 Initial Frequency Adjust Function first_hz_adjut() Set tcc0 Count source = f8 ______ Select INT 3 rising edge ______ Select INT 3 interrupt Set tcc1...
  • Page 9 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.2.4 Frequency Adjustment Value Write Function [Argument] write_ringadjust_data(unsigned char data) data: HR1 adjustment value EW1 mode enter Enter the CPU rewrite mode 1 (EW1 mode).
  • Page 10 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.2.6 EW1 Mode Exit Function flash_close_ew1_mode() If the fmr01 bit is set to “0” (CPU rewrite mode disabled), the fmr11 bit is also fmr01 = 0 set to “0”...
  • Page 11 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.2.8 Full Status Check Function chk_flash_status() Yes (fmr06 = 1 & fmr07 = 1) Command error? return FLASH_CMD_ERROR Yes ( fmr07 = 1) Erase error?
  • Page 12 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency _______ 4.2.9 High-speed On-chip Ooscillator Adjust Function (INT 3 Interrupt Function) Interrupt processing to be executed when a rising edge of the input int3_hz_in() ______ signal to the I N T 3 pin is detected.
  • Page 13: Sample Program

    Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency 4.3 Sample program /******************************************************************************************** File Name : main.c Contents : Main program of High frequency judgement R8C/11 Group Copyright, 2004 RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Version : 1.00...
  • Page 14 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency asm("FCLR I"); /* Interrupt disable */ sfr_init(); /* Initial setting of SFR registers */ /* Confirm Adjusting */ if (*HR1_FLASH_ROM == 0xff){ first_hz_adjut(); }else{ /* Setting high-speed on-chip oscillator control register1 */ prc0 = 1;...
  • Page 15 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency while(1){ /* Second frequency measure */ while (ir_int3ic == 0); /* int3 upedge */ ir_int3ic = 0; in_timerc1 = tm0; /* loading timerC */ dat = in_timerc1 - in_timerc0; /* Calculate palse width */ in_timerc0 = in_timerc1;...
  • Page 16 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency /************************************************************************************ Name: flash_open_ew1_mode Parameters: None Returns: None Description: Open Flash write mode ************************************************************************************/ void flash_open_ew1_mode(void){ /* Slow down cpu clock */ prc0 = 1; cm06 = 1;...
  • Page 17 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency /************************************************************************************ Name: chk_flash_status Parameters: None Returns: flash status Description: Check a flash full status ************************************************************************************/ int chk_flash_status(void){ /* Check of Command error */ if (fmr06 == 1 && fmr07 == 1) return(FLASH_CMD_ERROR);...
  • Page 18 R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency /* 60Hz judgement */ /* Equal to 60Hz */ if (dat == 166){ /* More than 60Hz */ }else if (dat < 166){ if (hr1 != 0x00){ prc0 = 1;...
  • Page 19 Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency Reference Hardware Manual R8C/11 Group Hardware Manual (Acquire the most current version from Renesas web-site) Web-site and contact for support Renesas Web-site http://www.renesas.com/ Contact for Renesas technical support Mail to : support_apl@renesas.com...
  • Page 20: Revision History

    R8C/11, R8C/13 Group Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency REVISION HISTORY Description Rev. Date Page Summary 1.00 July 16, 2004 First edition issued REJ05B0471-0100Z/Rev.1.00 July 2004 Page 20 of 21...
  • Page 21: Keep Safety First In Your Circuit Designs

    Notes regarding these materials! Notes regarding these materials 1. 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.

This manual is also suitable for:

R8c/13