8.3.3 Coding Example of Initial Setting Routine

A coding example of the PowerOn_Reset_PC function is shown here.

For the actual initial setting routine created in the integrated development environment, refer to 8.4 Coding Example.

#include     <machine.h>
#include     <_h_c_lib.h>
#include     "typedefine.h"
#include     "stacksct.h"
 
#ifdef __cplusplus
extern "C" {
#endif
void PowerOn_Reset_PC(void);
void main(void);
#ifdef __cplusplus
}
#endif
 
#ifdef __cplusplus                      // Use SIM I/O
extern "C" {
#endif
extern void _INITLIB(void);
#ifdef __cplusplus
}
#endif
 
#define PSW_init  0x00010000
#define FPSW_DPSW_init 0x00000100
 
#pragma section ResetPRG
#pragma entry PowerOn_Reset_PC
void PowerOn_Reset_PC(void)
{ 
#if (__RX_ISA_VERSION__ >= 2) || defined(__RXV2)
    set_extb(__sectop("EXCEPTVECT"));
#endif
    set_intb(__sectop("C$VECT"));
#ifdef __FPU
    set_fpsw(FPSW_DPSW_init);
#ifdef __DPFPU
    __set_dpsw(FPSW_DPSW_init);
#endif
#endif
#ifdef __TFU
    __init_tfu();
#endif
 
    _INITSCT();
    _INITLIB();
    set_psw(PSW_init);
    main();
    brk();
}