src/fw_sys.c
/**
 * Change system clock
 * - invoke this in the beginning of code
 * - don't invoke this if the target frequency is already set by STC-ISP
*/
Change system clock
- invoke this in the beginning of code
- don't invoke this if the target frequency is already set by STC-ISP
Change system clock - invoke this in the beginning of code - don ' t invoke this if the target frequency is already set by STC - ISP
void SYS_SetClock(void)
{
    uint16_t i = 0; uint8_t j = 5;
    P_SW2 = 0x80;
    if (CLKDIV != (__CONF_CLKDIV))
    {
        CLKDIV = (__CONF_CLKDIV);
        do { 
            while (--i);
        } while (--j);
    }
    P_SW2 = 0x00;
    clkdiv = (__CONF_CLKDIV == 0)? 1 : __CONF_CLKDIV;
    SYS_SetFOSC(__CONF_IRCBAND, __CONF_VRTRIM, __CONF_IRTRIM, __CONF_LIRTRIM);
    while (--i); 
}
void SYS_SetClock ( void ) { uint16_t i = 0 ; uint8_t j = 5 ; P_SW2 = 0x80 ; if ( CLKDIV != ( __CONF_CLKDIV ) ) { CLKDIV = ( __CONF_CLKDIV ) ; do { while ( -- i ) ; } while ( -- j ) ; } P_SW2 = 0x00 ; clkdiv = ( __CONF_CLKDIV == 0 ) ? 1 : __CONF_CLKDIV ; SYS_SetFOSC ( __CONF_IRCBAND , __CONF_VRTRIM , __CONF_IRTRIM , __CONF_LIRTRIM ) ; while ( -- i ) ; }
Change system clock
 - invoke this in the beginning of code
 - don't invoke this if the target frequency is already set by STC-ISP
Change system clock - invoke this in the beginning of code - don ' t invoke this if the target frequency is already set by STC - ISP
// Wait a while after clock changed, or it may block the main process // Wait