void PowerON_Reset_PC(void)
{
#ifdef __RXV2
    set_extb(__sectop("EXCEPTVECT"));
#endif
    set_intb(__sectop("C$VECT"));

#ifdef __ROZ                        /* Initialize FPSW */
#define _ROUND 0x00000001           /* Let FPSW RMbits=01 (round to zero) */
#else
#define _ROUND 0x00000000           /* Let FPSW RMbits=00 (round to nearest) */
#endif
#ifdef __DOFF
#define _DENOM 0x00000100           /* Let FPSW DNbit=1 (denormal as zero) */
#else
#define _DENOM 0x00000000           /* Let FPSW DNbit=0 (denormal as is) */
#endif

    set_fpsw(FPSW_init | _ROUND | _DENOM);

    _INITSCT();                     /* Initialize Sections */
    HardwareSetup();                /* Use Hardware Setup */
    nop();
    set_psw(PSW_init);              /* Set Ubit & Ibit for PSW */
    main();
    brk();
}
Example #2
0
void PowerON_Reset_PC(void)
{ 
	set_intb((void*)__sectop("C$VECT"));
//	set_fpsw(FPSW_init);

	_INITSCT();

//	_INIT_IOLIB();					// Remove the comment when you use SIM I/O

//	errno=0;						// Remove the comment when you use errno
//	srand((_UINT)1);				// Remove the comment when you use rand()
//	_s1ptr=NULL;					// Remove the comment when you use strtok()
		
//	HardwareSetup();				// Use Hardware Setup
    nop();

//	_CALL_INIT();					// Remove the comment when you use global class object

	set_psw(PSW_init);				// Set Ubit & Ibit for PSW
//	Change_PSW_PM_to_UserMode();	// DO NOT CHANGE TO USER MODE IF USING FREERTOS!
	( void ) Change_PSW_PM_to_UserMode; // Just to avoid compiler warnings.

	main();

//	_CLOSEALL();					// Use SIM I/O
	
//	_CALL_END();					// Remove the comment when you use global class object

	brk();
}
Example #3
0
/******************************************************************************
* Outline       : PowerON_Reset_PC
* Description   : This program is the MCU's entry point from a power-on reset.
*                 The function configures the MCU stack, then calls the
*                 HardwareSetup function and main function sequentially.
* Argument      : none
* Return value  : none
******************************************************************************/
void PowerON_Reset_PC(void)
{
    /* Initialise the MCU processor word */
#if __RENESAS_VERSION__ >= 0x01010000    
    set_intb((void *)__sectop("C$VECT"));
#else
    set_intb((unsigned long)__sectop("C$VECT"));
#endif    
    set_fpsw(FPSW_init);

    /* Initialise the MCU stack area */
    _INITSCT();

    /* Configure the MCU and YRDK hardware */
    HardwareSetup();

    /* Change the MCU's usermode from supervisor to user */        
    nop();
    set_psw(PSW_init);      
    Change_PSW_PM_to_UserMode();

    /* Call the main program function */
    main();

    /* Invoke a break interrupt */
    brk();
}
Example #4
0
void PowerON_Reset(void)
{
    set_intb(__sectop("C$VECT"));

    _INITSCT();                     /* Initialize Sections */
    HardwareSetup();                /* Use Hardware Setup */
    nop();
    set_psw(PSW_init);              /* Set Ubit & Ibit for PSW */
    main();
    brk();
}
Example #5
0
void PowerON_Reset_PC(void)
{ 
#ifdef __RXV2
	set_extb(__sectop("EXCEPTVECT"));
#endif
	set_intb(__sectop("C$VECT"));

#ifdef __FPU
#ifdef __ROZ					// Initialize FPSW
#define _ROUND 0x00000001			// Let FPSW RMbits=01 (round to zero)
#else
#define _ROUND 0x00000000			// Let FPSW RMbits=00 (round to nearest)
#endif
#ifdef __DOFF
#define _DENOM 0x00000100			// Let FPSW DNbit=1 (denormal as zero)
#else
#define _DENOM 0x00000000			// Let FPSW DNbit=0 (denormal as is)
#endif
	set_fpsw(FPSW_init | _ROUND | _DENOM);
#endif

	_INITSCT();

//	_INIT_IOLIB();					// Use SIM I/O

//	errno=0;						// Remove the comment when you use errno
//	srand((_UINT)1);					// Remove the comment when you use rand()
//	_s1ptr=NULL;					// Remove the comment when you use strtok()
		
//	HardwareSetup();				// Use Hardware Setup
    nop();

//	_CALL_INIT();					// Remove the comment when you use global class object

	set_psw(PSW_init);				// Set Ubit & Ibit for PSW
//	chg_pmusr();					// Remove the comment when you need to change PSW PMbit (SuperVisor->User)

	main();

//	_CLOSEALL();					// Use SIM I/O
	
//	_CALL_END();					// Remove the comment when you use global class object

	brk();
}
void PowerON_Reset_PC(void)
{
    /* Initialise the MCU processor word */
    set_intb((unsigned long)__sectop("C$VECT"));
    set_fpsw(FPSW_init);
    
    /* Initialise the MCU stack area */
    _INITSCT();

    /* Configure the MCU and YRDK hardware */
    //HardwareSetup();

    /* Change the MCU's usermode from supervisor to user */        
    nop();
    set_psw(PSW_init);      
    //Change_PSW_PM_to_UserMode();

    /* Call the main program function */
    __enable_interrupt();
	main();

    /* Invoke a break interrupt */
    brk();
}
/***********************************************************************************************************************
* 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)
{
    /* Stack pointers are setup prior to calling this function - see comments above */    
    
    /* Initialize the Interrupt Table Register */
    set_intb((void *)__sectop("C$VECT"));

    /* Initialize the Exception Table Register */
    set_extb((void *)__sectop("EXCEPTVECT"));

    /* 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
    chg_pmusr() ;
#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(). */
    }
}
Example #8
0
void Cmt0IntFunc()
{

	PORT1.DR.BIT.B1 = 1;
	psw_value = get_psw();//////////////////////////
	psw_value |= 0x00010000;
	set_psw(psw_value);

	
//	HIT_now_voltage_f_out = 37;//27.2;
	HIT_curren_aa_q_max_cmt0 = HIT_now_voltage_f_out/HIT_kv;//calculate the current_sum_lim  MAX
/* short current alarm */
	HIT_id_fb_square = HIT_id_fb*HIT_id_fb;
	HIT_iq_fb_square = HIT_iq_fb*HIT_iq_fb;
	HIT_idq_square = HIT_id_fb_square+HIT_iq_fb_square;
	
	if(HIT_idq_square > HIT_IDQ_SPE_SQUARE)
	{
		HIT_shortime_cur_count++;
		if(HIT_shortime_cur_count > 9)//serial 10ms match
		{
			//HIT_shortime_curr_alam
			HIT_shortime_cur_count = 0;	
		}	
	}
	else
	{
		HIT_shortime_cur_count = 0;		
	}
/* short current alarm end */ 
	HIT_positon_Kp_trans_f = HIT_positon_Kp_int_float;//(float)HIT_positon_Kp_int;//HIT_positon_Kp_int_float;//(float)HIT_positon_Kp_int;//transfer to trsmit parameter
	HIT_positon_Kp_trans_f = HIT_positon_Kp_trans_f * HIT_TWOPIE/HIT_POSITION_16WEI;
	HIT_positon_Kp_f = HIT_positon_Kp_trans_f;//transfer to real register
	
	HIT_shouchaoqi();
/////////////////////////////////////////////////////////////////////////
/*if((HIT_run_mode == 3)||(HIT_run_mode == 4))//((HIT_run_mode == 2)||(HIT_run_mode == 3))
{
	HIT_SERVO_PORT = PORT1.PORT.BIT.B0;
	if(HIT_SERVO_PORT == 0)
	{
		HIT_pwm_mode_choose = 1;	
	}
	if(HIT_pwm_mode_choose == 1)
	{
		HIT_ready_go = 1;	
	}
	if(HIT_SERVO_PORT == 1)
	{
		HIT_pwm_mode_choose = 2;	
	}
}*/
/////////////////////////////////////////////////////////////////////////
	if(HIT_alarm == 1)// 报警输出
	{
		PORT9.DR.BIT.B2 = 0;//ALM 	
	}
	if((HIT_ready_go == 0)||(HIT_alarm == 1))//伺服准备未完成
	{
		PORT9.DR.BIT.B1 = 1;//S_RDY	
	}
	if((HIT_ready_go == 1)&&(HIT_alarm == 0))//伺服准备完成
	{
		HIT_baozha_num++;
		if(HIT_baozha_num > 500)
		{
			PORT9.DR.BIT.B1 = 0;//S_RDY	
			HIT_baozha_num = 501;
		}
	}
//	if((HIT_WLw_ref == 0)&&((HIT_pos_org_f > -0.5)&&(HIT_pos_org_f < 0.5)))//&&(HIT_speedlpf == 0))
	if(((HIT_a_phase_sum <= 3)&&(HIT_a_phase_sum >= -3))&&((HIT_pos_org_int <= 200)&&(HIT_pos_org_int > -200)))//&&(HIT_speedlpf == 0))
	{
		PORT2.DR.BIT.B4 = 0;//CUIN
	}
	else
	{
		PORT2.DR.BIT.B4 = 1;//CUIN	
	}
/////////////////////////////////////////////////////////////////////////
	PORT1.DR.BIT.B1 = 0;


}
    //#pragma section P UserAppStartSect        // Output PowerON_Reset to PResetPRG section
    void UserAppStart(void)
#endif
{
    /* Stack pointers are setup prior to calling this function - see comments above */    
    
    /* Initialise the MCU processor word */
#if __RENESAS_VERSION__ >= 0x01010000    
    set_intb((void *)__sectop("C$VECT"));
#else
    set_intb((unsigned long)__sectop("C$VECT"));
#endif    

#if (BSP_CFG_USE_CGC_MODULE == 0)
    /* Switch to high-speed operation */
    operating_frequency_set();
#else
    cgc_clock_config();
#endif

    /* 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(). */
    }
}