
REJ05B0471-0100Z/Rev.1.00 July 2004 Page 13 of 21
R8C/11, R8C/13 Group
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 *
* *
********************************************************************************************/
/************************************
* include file *
*************************************/
#include "sfr_r811.h" /* Definition of the R8C/11 SFR */
#include "sfr_r811_flash.h" /* Definition of the R8C/11 flash SFR */
/************************************
* prototype definition *
*************************************/
void sfr_init(void);
void first_hz_adjut(void);
void write_ringadjust_data(unsigned char);
void flash_open_ew1_mode(void);
void flash_close_ew1_mode(void);
int flash_byte_write(unsigned char * , unsigned char);
int chk_flash_status(void);
/************************************
* global label *
*************************************/
unsigned int in_timerc0; /* input_timerc loading0 */
unsigned int in_timerc1; /* input_timerc loading1 */
unsigned int dat; /* frequency */
unsigned int old_timer; /* input_timerc old loading */
unsigned int new_timer; /* input_timerc new loading */
union byte_def cnt_flag;
#define f_downflag cnt_flag.bit.b0 /* Hz under flag */
#define f_upflag cnt_flag.bit.b1 /* Hz over flag */
#define HR1_FLASH_ROM ((unsigned char *)0xfedb) /* hr1 adjust data store rom address */
/************************************
* macro definition *
*************************************/
enum{
FLASH_OK,
FLASH_CMD_ERROR,
FLASH_ERASE_ERROR,
FLASH_PROG_ERROR
};
/************************************************************************************
Name: main
Parameters: None
Returns: None
Description: High frequency judgement
************************************************************************************/
main() {
/* Setting system clock */
prc0 = 1; /* Protect off */
cm06 = 1;
cm16 = 0;
cm17 = 0; /* 1/1 */
hr00 = 1; /* On-chip oscillator on */
asm("nop"); /* waiting */
asm("nop");
asm("nop");
hr01 = 1;
cm06 = 0; /* 1/8 */
prc0 = 0; /* Protect on */