Esempio n. 1
0
void Mcu_Init(const Mcu_ConfigType *configPtr)
{
  VALIDATE( ( NULL != configPtr ), MCU_INIT_SERVICE_ID, MCU_E_PARAM_CONFIG );

#if !defined(USE_SIMULATOR)
  Mcu_CheckCpu();
#endif

  memset(&Mcu_Global.stats,0,sizeof(Mcu_Global.stats));

  Irq_Enable();

  Mcu_Global.config = configPtr;
  Mcu_Global.initRun = 1;
}
Esempio n. 2
0
void Mcu_Init(const Mcu_ConfigType *configPtr)
{
	VALIDATE( ( NULL != configPtr ), MCU_INIT_SERVICE_ID, MCU_E_PARAM_CONFIG );

	Mcu_Arc_InitPre(configPtr);


#if defined(CFG_MPC560X) || defined(CFG_MPC563XM)
	/* Disable watchdog. Watchdog is enabled default after reset.*/
 	SWT.SR.R = 0x0000c520;     /* Write keys to clear soft lock bit */
 	SWT.SR.R = 0x0000d928;
 	SWT.CR.R = 0x8000010A;     /* Disable watchdog */
#if defined(USE_WDG)
#if defined(CFG_MPC5604P)
	SWT.TO.R = 0x7d000;         /* set the timout to 500ms, , 16khz clock */
#elif defined(CFG_MPC563XM)
	SWT.TO.R = 4000000;         	/* set the timout to 500ms, 8mhz crystal clock */
#else
	SWT.TO.R = 0xfa00;         	/* set the timout to 500ms, 128khz clock */
#endif
	SWT.CR.R = 0x8000011B;      /* enable watchdog */
#endif
#endif

    if( !SIMULATOR() ) {
    	Mcu_CheckCpu();
    }

    memset(&Mcu_Global.stats,0,sizeof(Mcu_Global.stats));

    // Setup memories
    Mcu_ConfigureFlash();

    Mcu_Global.config = configPtr;

#if defined(CFG_MPC560X)
    /* Enable DRUN, RUN0, SAFE, RESET modes */
    ME.MER.R = 0x0000001D;
	/*	MPC5604P: CMU_0 must be initialized differently from the default value
                in case of 8 MHz crystal. */
#if defined (CFG_MPC5604P)
	CGM.CMU_0_CSR.R = 0x00000004;
#endif
#endif

    Mcu_Global.initRun = 1;

    if( Mcu_Global.config->McuClockSrcFailureNotification == TRUE  ) {
#if defined(CFG_MPC560X)
    	/*not support*/
#else
    	ISR_INSTALL_ISR1("LossOfLock", Mcu_LossOfLock, PLL_SYNSR_LOLF, 10 , 0 );
#if defined(CFG_MPC5516)  || defined(CFG_MPC5668)
    	FMPLL.ESYNCR2.B.LOLIRQ = 1;
#elif defined(CFG_MPC5554) || defined(CFG_MPC5567) || defined(CFG_MPC563XM)
    	FMPLL.SYNCR.B.LOLIRQ = 1;
#endif
    	ISR_INSTALL_ISR1("LossOfClock", Mcu_LossOfClock, PLL_SYNSR_LOLF, 10 , 0 );
#if defined(CFG_MPC5516) || defined(CFG_MPC5668)
    	FMPLL.ESYNCR2.B.LOCIRQ = 1;
#elif defined(CFG_MPC5554) || defined(CFG_MPC5567) || defined(CFG_MPC563XM)
    	FMPLL.SYNCR.B.LOCIRQ = 1;
#endif
#endif

    }
#if defined(CFG_MPC5668)
    /* Enable ecc error reporting */
    ECSM.ECR.B.EPFNCR = 1;
#else
    /* TODO: add support */
#endif
    Mcu_Arc_InitPost(configPtr);

}