Download Print this page

Renesas R8C/11 Application Note page 15

Hide thumbs Also See for R8C/11:

Advertisement

Adjusting the Frequency of the High-speed On-chip Oscillator Using a Commercial Frequency
while(1){
/* Second frequency measure */
while (ir_int3ic == 0);
ir_int3ic = 0;
in_timerc1 = tm0;
dat = in_timerc1 - in_timerc0; /* Calculate palse width */
in_timerc0 = in_timerc1;
dat = dat / 100;
/* 60Hz judgement */
/* Equal to 60Hz */
if (dat == 166){
/* flash write & software reset */
write_ringadjust_data(hr1);
return;
/* More than 60Hz */
}else if (dat < 166){
f_downflag = 1;
if (f_upflag == 1){
}
if (hr1 != 0x00){
}
/* Less than 60Hz */
}else if (dat > 166){
f_upflag = 1;
if (f_downflag == 1){
}
if (hr1 < 0x7f){
}
}
}
}
/************************************************************************************
Name:
write_ringadjust_data
Parameters:
Adjust data
Returns:
None
Description:
Software reset after flash writing
************************************************************************************/
void write_ringadjust_data(unsigned char data){
/* Starting of flash write mode */
flash_open_ew1_mode();
/* Write a high-speed on-chip oscillator register1 adjusted data ( Retry is 4 times ) */
flash_byte_write(HR1_FLASH_ROM, data);
/* Finishing of flash write mode */
flash_close_ew1_mode();
/* Software reset */
prc1 = 1;
pm03 = 1;
prc1 = 0;
}
REJ05B0471-0100Z/Rev.1.00
/* flash write & software reset */
write_ringadjust_data(hr1);
return;
/* Minimum of high-speed on-chip oscillator register1 */
prc0 = 1;
/* Protect off */
--hr1;
/* Sub high-speed on-chip oscillator register1 */
prc0 = 0;
/* Protect on */
/* flash write & software reset */
write_ringadjust_data(hr1);
return;
/* Maximum of high-speed on-chip oscillator register1 */
prc0 = 1;
/* Protect off */
++hr1;
/* Add high-speed on-chip oscillator register1 */
prc0 = 0;
/* Protect on */
/* int3 upedge */
/* loading timerC */
July 2004
R8C/11, R8C/13 Group
Page 15 of 21

Advertisement

loading

This manual is also suitable for:

R8c/13