projects/echo/r_bsp/board/grsakurarx63n/resetprg.c
void PowerON_Reset_PC(void)
{
    /* Stack pointers are setup prior to calling this function - see comments above */    
    
    /* Initialize the MCU processor word */
#if __RENESAS_VERSION__ >= 0x01010000    
    set_intb((void *)__sectop("C$VECT"));
#else
    set_intb((unsigned long)__sectop("C$VECT"));
#endif    

    /* Initialize FPSW for floating-point operations */
#ifdef __ROZ
#define FPU_ROUND 0x00000001  /* Let FPSW RMbits=01 (round to zero) */
#else 
#define FPU_ROUND 0x00000000  /* Let FPSW RMbits=00 (round to nearest) */
#endif 
#ifdef __DOFF 
#define FPU_DENOM 0x00000100  /* Let FPSW DNbit=1 (denormal as zero) */
#else 
#define FPU_DENOM 0x00000000  /* Let FPSW DNbit=0 (denormal as is) */
#endif 

    set_fpsw(FPSW_init | FPU_ROUND | FPU_DENOM);

    /* Switch to high-speed operation */
    operating_frequency_set();

    /* If the warm start Pre C runtime callback is enabled, then call it. */
#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_PRE_C_FUNCTION();
#endif

    /* Initialize C runtime environment */
    _INITSCT();

    /* If the warm start Post C runtime callback is enabled, then call it. */
#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_POST_C_FUNCTION();
#endif

#if BSP_CFG_IO_LIB_ENABLE == 1
    /* Comment this out if not using I/O lib */
    _INIT_IOLIB();
#endif

    /* Initialize MCU interrupt callbacks. */
    bsp_interrupt_open();

    /* Initialize register protection functionality. */
    bsp_register_protect_open();

    /* Configure the MCU and board hardware */
    hardware_setup();

    /* Change the MCU's user mode from supervisor to user */
    nop();
    set_psw(PSW_init);      
#if BSP_CFG_RUN_IN_USER_MODE==1
    /* Use chg_pmusr() intrinsic if possible. */
    #if __RENESAS_VERSION__ >= 0x01010000
    chg_pmusr() ;
    #else
    Change_PSW_PM_to_UserMode();
    #endif
#endif

    /* Enable the bus error interrupt to catch accesses to illegal/reserved areas of memory */
    R_BSP_InterruptControl(BSP_INT_SRC_BUS_ERROR, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR);

    /* Call the main program function (should not return) */
    main();
    
#if BSP_CFG_IO_LIB_ENABLE == 1
    /* Comment this out if not using I/O lib - cleans up open files */
    _CLOSEALL();
#endif

    /* BCH - 01/16/2013 */
    /* Infinite loop is intended here. */    
    while(1) /* PRQA S 2740 */
    {
        /* Infinite loop. Put a breakpoint here if you want to catch an exit of main(). */
    }
}
/***********************************************************************************************************************
* Function name: PowerON_Reset_PC
* Description  : This function is the MCU's entry point from a power-on reset.
*                The following steps are taken in the startup code:
*                1. The User Stack Pointer (USP) and Interrupt Stack Pointer (ISP) are both set immediately after entry 
*                   to this function. The USP and ISP stack sizes are set in the file bsp_config.h.
*                   Default sizes are USP=4K and ISP=1K.
*                2. The interrupt vector base register is set to point to the beginning of the relocatable interrupt 
*                   vector table.
*                3. The MCU is setup for floating point operations by setting the initial value of the Floating Point 
*                   Status Word (FPSW).
*                4. The MCU operating frequency is set by configuring the Clock Generation Circuit (CGC) in
*                   operating_frequency_set.
*                5. Calls are made to functions to setup the C runtime environment which involves initializing all 
*                   initialed data, zeroing all uninitialized variables, and configuring STDIO if used
*                   (calls to _INITSCT and _INIT_IOLIB).
*                6. Board-specific hardware setup, including configuring I/O pins on the MCU, in hardware_setup.
*                7. Global interrupts are enabled by setting the I bit in the Program Status Word (PSW), and the stack 
*                   is switched from the ISP to the USP.  The initial Interrupt Priority Level is set to zero, enabling 
*                   any interrupts with a priority greater than zero to be serviced.
*                8. The processor is optionally switched to user mode.  To run in user mode, set the macro 
*                   BSP_CFG_RUN_IN_USER_MODE above to a 1.
*                9. The bus error interrupt is enabled to catch any accesses to invalid or reserved areas of memory.
*
*                Once this initialization is complete, the user's main() function is called.  It should not return.
* Arguments    : none
* Return value : none
***********************************************************************************************************************/
Function name: PowerON_Reset_PC
Description  : This function is the MCU's entry point from a power-on reset.
The following steps are taken in the startup code:
1. The User Stack Pointer (USP) and Interrupt Stack Pointer (ISP) are both set immediately after entry
to this function. The USP and ISP stack sizes are set in the file bsp_config.h.
Default sizes are USP=4K and ISP=1K.
2. The interrupt vector base register is set to point to the beginning of the relocatable interrupt
vector table.
3. The MCU is setup for floating point operations by setting the initial value of the Floating Point
Status Word (FPSW).
4. The MCU operating frequency is set by configuring the Clock Generation Circuit (CGC) in
operating_frequency_set.
5. Calls are made to functions to setup the C runtime environment which involves initializing all
initialed data, zeroing all uninitialized variables, and configuring STDIO if used
(calls to _INITSCT and _INIT_IOLIB).
6. Board-specific hardware setup, including configuring I/O pins on the MCU, in hardware_setup.
7. Global interrupts are enabled by setting the I bit in the Program Status Word (PSW), and the stack
is switched from the ISP to the USP.  The initial Interrupt Priority Level is set to zero, enabling
any interrupts with a priority greater than zero to be serviced.
8. The processor is optionally switched to user mode.  To run in user mode, set the macro
BSP_CFG_RUN_IN_USER_MODE above to a 1.
9. The bus error interrupt is enabled to catch any accesses to invalid or reserved areas of memory.

Once this initialization is complete, the user's main() function is called.  It should not return.
Arguments    : none
Return value : none
Function name : PowerON_Reset_PC Description : This function is the MCU ' s entry point from a power - on reset . The following steps are taken in the startup code : 1 . The User Stack Pointer ( USP ) and Interrupt Stack Pointer ( ISP ) are both set immediately after entry to this function . The USP and ISP stack sizes are set in the file bsp_config . h . Default sizes are USP = 4K and ISP = 1K . 2 . The interrupt vector base register is set to point to the beginning of the relocatable interrupt vector table . 3 . The MCU is setup for floating point operations by setting the initial value of the Floating Point Status Word ( FPSW ) . 4 . The MCU operating frequency is set by configuring the Clock Generation Circuit ( CGC ) in operating_frequency_set . 5 . Calls are made to functions to setup the C runtime environment which involves initializing all initialed data zeroing all uninitialized variables and configuring STDIO if used ( calls to _INITSCT and _INIT_IOLIB ) . 6 . Board - specific hardware setup including configuring I / O pins on the MCU in hardware_setup . 7 . Global interrupts are enabled by setting the I bit in the Program Status Word ( PSW ) and the stack is switched from the ISP to the USP . The initial Interrupt Priority Level is set to zero enabling any interrupts with a priority greater than zero to be serviced . 8 . The processor is optionally switched to user mode . To run in user mode set the macro BSP_CFG_RUN_IN_USER_MODE above to a 1 . 9 . The bus error interrupt is enabled to catch any accesses to invalid or reserved areas of memory . Once this initialization is complete the user ' s main () function is called . It should not return . Arguments : none Return value : none
void PowerON_Reset_PC(void)
{
#if __RENESAS_VERSION__ >= 0x01010000    
    set_intb((void *)__sectop("C$VECT"));
#else
    set_intb((unsigned long)__sectop("C$VECT"));
#endif    
#ifdef __ROZ
#define FPU_ROUND 0x00000001  /* Let FPSW RMbits=01 (round to zero) */
#else 
#define FPU_ROUND 0x00000000  /* Let FPSW RMbits=00 (round to nearest) */
#endif 
#ifdef __DOFF 
#define FPU_DENOM 0x00000100  /* Let FPSW DNbit=1 (denormal as zero) */
#else 
#define FPU_DENOM 0x00000000  /* Let FPSW DNbit=0 (denormal as is) */
#endif 
    set_fpsw(FPSW_init | FPU_ROUND | FPU_DENOM);
    operating_frequency_set();
#if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_PRE_C_FUNCTION();
#endif
    _INITSCT();
#if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1
     BSP_CFG_USER_WARM_START_POST_C_FUNCTION();
#endif
#if BSP_CFG_IO_LIB_ENABLE == 1
    _INIT_IOLIB();
#endif
    bsp_interrupt_open();
    bsp_register_protect_open();
    hardware_setup();
    nop();
    set_psw(PSW_init);      
#if BSP_CFG_RUN_IN_USER_MODE==1
    #if __RENESAS_VERSION__ >= 0x01010000
    chg_pmusr() ;
    #else
    Change_PSW_PM_to_UserMode();
    #endif
#endif
    R_BSP_InterruptControl(BSP_INT_SRC_BUS_ERROR, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR);
    main();
#if BSP_CFG_IO_LIB_ENABLE == 1
    _CLOSEALL();
#endif
    while(1) 
    {
    }
}
void PowerON_Reset_PC ( void ) { #if __RENESAS_VERSION__ >= 0x01010000 set_intb ( ( void * ) __sectop ( " " ) ) ; #else set_intb ( ( unsigned long ) __sectop ( " " ) ) ; #endif #ifdef __ROZ #define FPU_ROUND  0x00000001  /* Let FPSW RMbits=01 (round to zero) */
 #else #define FPU_ROUND  0x00000000  /* Let FPSW RMbits=00 (round to nearest) */
 #endif #ifdef __DOFF #define FPU_DENOM  0x00000100  /* Let FPSW DNbit=1 (denormal as zero) */
 #else #define FPU_DENOM  0x00000000  /* Let FPSW DNbit=0 (denormal as is) */
 #endif set_fpsw ( FPSW_init | FPU_ROUND | FPU_DENOM ) ; operating_frequency_set ( ) ; #if BSP_CFG_USER_WARM_START_CALLBACK_PRE_INITC_ENABLED == 1 BSP_CFG_USER_WARM_START_PRE_C_FUNCTION ( ) ; #endif _INITSCT ( ) ; #if BSP_CFG_USER_WARM_START_CALLBACK_POST_INITC_ENABLED == 1 BSP_CFG_USER_WARM_START_POST_C_FUNCTION ( ) ; #endif #if BSP_CFG_IO_LIB_ENABLE == 1 _INIT_IOLIB ( ) ; #endif bsp_interrupt_open ( ) ; bsp_register_protect_open ( ) ; hardware_setup ( ) ; nop ( ) ; set_psw ( PSW_init ) ; #if BSP_CFG_RUN_IN_USER_MODE == 1 #if __RENESAS_VERSION__ >= 0x01010000 chg_pmusr ( ) ; #else Change_PSW_PM_to_UserMode ( ) ; #endif #endif R_BSP_InterruptControl ( BSP_INT_SRC_BUS_ERROR , BSP_INT_CMD_INTERRUPT_ENABLE , FIT_NO_PTR ) ; main ( ) ; #if BSP_CFG_IO_LIB_ENABLE == 1 _CLOSEALL ( ) ; #endif while ( 1 ) { } }
Function name: PowerON_Reset_PC
Description  : This function is the MCU's entry point from a power-on reset.
Function name : PowerON_Reset_PC Description : This function is the MCU ' s entry point from a power - on reset .
/* Stack pointers are setup prior to calling this function - see comments above */ /* Initialize the MCU processor word */ /* Initialize FPSW for floating-point operations */ /* Switch to high-speed operation */ /* If the warm start Pre C runtime callback is enabled, then call it. */ /* Initialize C runtime environment */ /* If the warm start Post C runtime callback is enabled, then call it. */ /* Comment this out if not using I/O lib */ /* Initialize MCU interrupt callbacks. */ /* Initialize register protection functionality. */ /* Configure the MCU and board hardware */ /* Change the MCU's user mode from supervisor to user */ /* Use chg_pmusr() intrinsic if possible. */ /* Enable the bus error interrupt to catch accesses to illegal/reserved areas of memory */ /* Call the main program function (should not return) */ /* Comment this out if not using I/O lib - cleans up open files */ /* BCH - 01/16/2013 */ /* Infinite loop is intended here. */ /* PRQA S 2740 */ /* Infinite loop. Put a breakpoint here if you want to catch an exit of main(). */