Example #1
0
/*
     实验名称:WDOG窗口看门狗
     实验平台:渡鸦开发板
     板载芯片:MK60DN512ZVQ10
 实验效果:开启看门狗的窗口模式,必须在规定的时间范围内喂狗,否则芯片复位
*/
int main(void)
{
    DelayInit();
    
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); /* LED */
    
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    /* 初始化看门狗 */
    WDOG_InitTypeDef WDOG_InitStruct1 = {0};
    WDOG_InitStruct1.mode = kWDOG_Mode_Window;   //设置看门狗为窗口模式
    WDOG_InitStruct1.windowInMs = 1000;   /* 开窗时间 设置为窗体模式后 喂狗必须在 看门狗开始计时后 1000 - 2000 MS内完成 多了少了都复位 比普通看门狗严格*/
    WDOG_InitStruct1.timeOutInMs = 2000; /* 时限 2000MS : 2000MS 内没有喂狗则复位 */
    WDOG_Init(&WDOG_InitStruct1);
    
    printf("\r\nSYSTEM RESET!!!!!!!%d\r\n", WDOG_GetResetCounter());
    printf("press any character to feed dog feed, must be in windows time\r\n");
    
    static uint32_t i;
    uint16_t ch;
    while(1)
    {
        if(UART_ReadByte(HW_UART0, &ch) == 0)
        {
            printf("wdog feed succ!\r\n");
            WDOG_Refresh(); //喂狗
            i = 0;
        }
        printf("cnt:i:%d\r", i++);
        DelayMs(100);
        GPIO_ToggleBit(HW_GPIOE, 6);
    }
}
Example #2
0
//================================================================================
// WDOG_enter_DefaultMode_from_RESET
//================================================================================
extern void WDOG_enter_DefaultMode_from_RESET(void) {

	// $[CMU_ClockEnable]
	/* Enable LE clock for CPU access to BURTC registers */
	CMU_ClockEnable(cmuClock_CORELE, true);
	// [CMU_ClockEnable]$

	// $[CMU_OscillatorEnable]
	CMU_OscillatorEnable(cmuOsc_LFRCO, true, true);
	// [CMU_OscillatorEnable]$

	// $[WDOG_Init]
	WDOG_Init_TypeDef watchdogInit = WDOG_INIT_DEFAULT;

	watchdogInit.debugRun = 0;
	watchdogInit.clkSel = wdogClkSelULFRCO;//1K频率
	watchdogInit.perSel = wdogPeriod_2k; //2K时钟周期,大约2s
	watchdogInit.swoscBlock = 0;
	watchdogInit.em4Block = 0;
	watchdogInit.lock = 0;
	watchdogInit.em3Run = 0;
	watchdogInit.em2Run = 0;
	WDOG_Init(&watchdogInit);
	// [WDOG_Init]$

}
Example #3
0
int main(void)
{
  //Clock Setup Internal Clock , CoreClock = 24M
	SystemClockSetup(ClockSource_IRC,CoreClock_24M);
	//DelayInit
	DelayInit();
	//LED Init
	LED_Init();
	
  //Init a debug UART prot
//	UART_DebugPortInit(UART1_RX_PC03_TX_PC04,115200);
	UART_DebugPortInit(UART0_RX_PB16_TX_PB17,115200);
	DisplayCPUInfo();



	
	GPIO_Test();
	MAG3110_Test();
	
	AT24Cxx_Test();
	SPIFLASH_Test();
	ADC_Test();
       WDOG_Init();
	while(1);

}
Example #4
0
int main(void)
{
    DelayInit();
    
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); /* LED */
    GPIO_QuickInit(HW_GPIOE, 26, kGPIO_Mode_IPU); /* KEY */
    
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    /* 初始化看门狗 */
    WDOG_InitTypeDef WDOG_InitStruct1;
    WDOG_InitStruct1.windowInMs = 0;
    WDOG_InitStruct1.mode = kWDOG_Mode_Normal;  //设置看门狗处于正常工作模式
    WDOG_InitStruct1.timeOutInMs = 2000; /* 时限 2000MS : 2000MS 内没有喂狗则复位 */
    WDOG_Init(&WDOG_InitStruct1);
    
    printf("WDOG test start!\r\n");
    printf("press KEY1 to feed dog within 2S or system with reset!\r\n");
    
    /* 点亮LED 然后熄灭  指示系统运行从新上电运行 */
    GPIO_WriteBit(HW_GPIOE, 6, 0);
    DelayMs(200);
    GPIO_WriteBit(HW_GPIOE, 6, 1);
    while(1)
    {
        if(GPIO_ReadBit(HW_GPIOE, 26) == 0) /* 按键被按下 */
        {
            /* 喂狗 防止复位 */
            printf("wdog feed! we have 2s\r\n");
            WDOG_Refresh(); //喂狗
            DelayMs(100);
        }
        DelayMs(10);
    }
}
Example #5
0
int main(void)
{
    uint8_t i;
    //初始化系统时钟 使用外部50M晶振 PLL倍频到100M
    SystemClockSetup(ClockSource_EX50M,CoreClock_100M);
    DelayInit();
    //初始化LED
    LED_Init(LED_PinLookup_CHKATOM, kNumOfLED);
    //KBI 初始化
    KBI_Init(KBI_PinLookup_CHKATOM, kNumOfKEY);
    //闪灯 制造复位效果
    for(i = 0; i < 10; i++)
    {
        LED_Toggle(kLED1);
        DelayMs(50);
    }
    //初始化看门狗 如果1000MS 内没有喂狗则 复位
    WDOG_Init(1000);
    while(1)
    {   
        KBI_Scan();
        if((KBI_GetKeyState(kKEY1) == kKBI_SINGLE))
        {  
            //如果案件按下 喂狗:
            WDOG_Feed();
        }
        //扫描间隔延时
        DelayMs(KBI_SCAN_PERIOD_IN_US/1000);
    }
}
Example #6
0
//看门狗任务
void AppWDOGTask(void *pdata)
{
	pdata=pdata; //防止编译器出错 无实际意义
	WDOG_Init(100); //开启看门狗 100MS超时复位
	while(1)
	{
		WDOG_Feed();
		OSTimeDlyHMSM(0, 0, 0, 50);
	}
}
Example #7
0
/**
 *    \brief    Initializes Watchdog.
 */
static void _hal_wdcInit(void)
{
    WDOG_Init_TypeDef wd = {
            false, false, false, false, false,
            false, wdogClkSelLFRCO, wdogPeriod_256k
    };

    /* disable watchdog at initialization*/
    wd.enable = 0;
    WDOG_Init( &wd );

} /* _hal_tcInit() */
int hal_watchdog_init(uint32_t expire_msecs)
{
#ifndef WATCHDOG_STUB
    wdog_config_t config;

    NVIC_SetVector(WDOG_EWM_IRQn, (uint32_t) nxp_wdt_irq_handler);
    WDOG_GetDefaultConfig(&config);
    config.timeoutValue = (expire_msecs * 32768ULL) / 1000;
    config.enableUpdate = true;
    WDOG_Init(wdog_base, &config);
#endif

    return (0);
}
Example #9
0
void _start(void)
{
	InterruptManager_Init();
	PWM_Init();
	
	PIT_Init();
	PIT_EnableTimer(0);

	WDOG_Init();

	while(1)
	{
		uint32_t volatile *r = (uint32_t*)0xE000E200;
		if((r[(64 - 16)/32] >> ((64-16) % 32)) & 1)
		{
			r = (uint32_t*)0x400FF04C;
			r[0] |= (1 << 22);
		}
	}
}
Example #10
0
static int mcux_wdog_setup(struct device *dev, u8_t options)
{
	const struct mcux_wdog_config *config = dev->config->config_info;
	struct mcux_wdog_data *data = dev->driver_data;
	WDOG_Type *base = config->base;

	if (!data->timeout_valid) {
		LOG_ERR("No valid timeouts installed");
		return -EINVAL;
	}

	data->wdog_config.workMode.enableStop =
		(options & WDT_OPT_PAUSE_IN_SLEEP) == 0;

	data->wdog_config.workMode.enableDebug =
		(options & WDT_OPT_PAUSE_HALTED_BY_DBG) == 0;

	WDOG_Init(base, &data->wdog_config);
	LOG_DBG("Setup the watchdog");

	return 0;
}
Example #11
0
void BSP_Configuration (void)
{
	GetCPUInfo ();	
	BSP_PowerInit ();
	BSP_PowerDown ();
	BSP_PowerUp ();	
	_BSP_NvicInit ();	
	UART_Configuration ();
	DisplayCPUInfo ();	
	/* SSD1906驱动初始化 使其初始化为RGB模式 */
	ILI_Configuration ();
	LIG_Configuration ();
	SSD1906_Configurationg ();
	STK_Configuration ();
	/* 继电器配置成断开连接 */
	RL_Configuration ();
	if(UM_GET_SYSTEMPARA&PARA_BEEP_MASK){
		API_GUI_OpenSpeak ();
		speak_jif = jiffies+30;
	}
	/* AD7687初始化配置 SPI模式,SCK与WV_Configuration共用,FTM初始化,采用中断方式采集 */
	AD7687_Configuration ();
	/* 波形发生器初始化配置,配置ML2035和AD5453,采用模拟SPI,在使用时,将SCK初始化为IO模式,在恢复SPI */
	WV_Configuration ();
	/* ADG409模拟开关芯片配置,通道一 */
	ADG_Configuration ();
	/* RTC初始化 */
	RTC_Init ();
	/* BAT电量初始化 */
	BSP_BatterCheckInit ();
	RF_Init ();
	//SN74121_Init ();
	//STK_Configuration ();
	STK_delay10ms(50);
	GUI_Get_Keymsg ();
	WDOG_Init (60000);
}
Example #12
0
void Peripherals_Init(void)
{
#ifdef NVIC_AUTOINIT
  NVIC_Init();
#endif /* NVIC_AUTOINIT */
#ifdef SIM_AUTOINIT
  SIM_Init();
#endif /* SIM_AUTOINIT */

#ifdef MCM_AUTOINIT
  MCM_Init();
#endif /* MCM_AUTOINIT */
#ifdef PMC_AUTOINIT
  PMC_Init();
#endif /* PMC_AUTOINIT */
#ifdef PORTA_AUTOINIT
  PORTA_Init();
#endif /* PORTA_AUTOINIT */
#ifdef PORTB_AUTOINIT
  PORTB_Init();
#endif /* PORTB_AUTOINIT */
#ifdef PORTC_AUTOINIT
  PORTC_Init();
#endif /* PORTC_AUTOINIT */
#ifdef PORTD_AUTOINIT
  PORTD_Init();
#endif /* PORTD_AUTOINIT */
#ifdef PORTE_AUTOINIT
  PORTE_Init();
#endif /* PORTE_AUTOINIT */

#ifdef ADC0_AUTOINIT
  ADC0_Init();
#endif /* ADC0_AUTOINIT */
#ifdef ADC1_AUTOINIT
  ADC1_Init();
#endif /* ADC1_AUTOINIT */
#ifdef AIPS0_AUTOINIT
  AIPS0_Init();
#endif /* AIPS0_AUTOINIT */
#ifdef AIPS1_AUTOINIT
  AIPS1_Init();
#endif /* AIPS1_AUTOINIT */
#ifdef AXBS_AUTOINIT
  AXBS_Init();
#endif /* AXBS_AUTOINIT */
#ifdef CAN0_AUTOINIT
  CAN0_Init();
#endif /* CAN0_AUTOINIT */
#ifdef CMP0_AUTOINIT
  CMP0_Init();
#endif /* CMP0_AUTOINIT */
#ifdef CMP1_AUTOINIT
  CMP1_Init();
#endif /* CMP1_AUTOINIT */
#ifdef CMP2_AUTOINIT
  CMP2_Init();
#endif /* CMP2_AUTOINIT */
#ifdef CMT_AUTOINIT
  CMT_Init();
#endif /* CMT_AUTOINIT */
#ifdef CRC_AUTOINIT
  CRC_Init();
#endif /* CRC_AUTOINIT */
#ifdef DAC0_AUTOINIT
  DAC0_Init();
#endif /* DAC0_AUTOINIT */
#ifdef DMAMUX_AUTOINIT
  DMAMUX_Init();
#endif /* DMAMUX_AUTOINIT */
#ifdef DMA_AUTOINIT
  DMA_Init();
#endif /* DMA_AUTOINIT */
#ifdef ENET_AUTOINIT
  ENET_Init();
#endif /* ENET_AUTOINIT */
#ifdef EWM_AUTOINIT
  EWM_Init();
#endif /* EWM_AUTOINIT */
#ifdef FB_AUTOINIT
  FB_Init();
#endif /* FB_AUTOINIT */
#ifdef FMC_AUTOINIT
  FMC_Init();
#endif /* FMC_AUTOINIT */
#ifdef FTFE_AUTOINIT
  FTFE_Init();
#endif /* FTFE_AUTOINIT */
#ifdef FTM0_AUTOINIT
  FTM0_Init();
#endif /* FTM0_AUTOINIT */
#ifdef FTM1_AUTOINIT
  FTM1_Init();
#endif /* FTM1_AUTOINIT */
#ifdef FTM2_AUTOINIT
  FTM2_Init();
#endif /* FTM2_AUTOINIT */
#ifdef FTM3_AUTOINIT
  FTM3_Init();
#endif /* FTM3_AUTOINIT */
#ifdef I2C0_AUTOINIT
  I2C0_Init();
#endif /* I2C0_AUTOINIT */
#ifdef I2C1_AUTOINIT
  I2C1_Init();
#endif /* I2C1_AUTOINIT */
#ifdef I2C2_AUTOINIT
  I2C2_Init();
#endif /* I2C2_AUTOINIT */
#ifdef I2S0_AUTOINIT
  I2S0_Init();
#endif /* I2S0_AUTOINIT */
#ifdef LLWU_AUTOINIT
  LLWU_Init();
#endif /* LLWU_AUTOINIT */
#ifdef LPTMR0_AUTOINIT
  LPTMR0_Init();
#endif /* LPTMR0_AUTOINIT */
#ifdef MPU_AUTOINIT
  MPU_Init();
#endif /* MPU_AUTOINIT */
#ifdef PDB0_AUTOINIT
  PDB0_Init();
#endif /* PDB0_AUTOINIT */
#ifdef PIT_AUTOINIT
  PIT_Init();
#endif /* PIT_AUTOINIT */
#ifdef PTA_AUTOINIT
  PTA_Init();
#endif /* PTA_AUTOINIT */
#ifdef PTB_AUTOINIT
  PTB_Init();
#endif /* PTB_AUTOINIT */
#ifdef PTC_AUTOINIT
  PTC_Init();
#endif /* PTC_AUTOINIT */
#ifdef PTD_AUTOINIT
  PTD_Init();
#endif /* PTD_AUTOINIT */
#ifdef PTE_AUTOINIT
  PTE_Init();
#endif /* PTE_AUTOINIT */
#ifdef RCM_AUTOINIT
  RCM_Init();
#endif /* RCM_AUTOINIT */
#ifdef RNG_AUTOINIT
  RNG_Init();
#endif /* RNG_AUTOINIT */
#ifdef RTC_AUTOINIT
  RTC_Init();
#endif /* RTC_AUTOINIT */
#ifdef SDHC_AUTOINIT
  SDHC_Init();
#endif /* SDHC_AUTOINIT */
#ifdef SMC_AUTOINIT
  SMC_Init();
#endif /* SMC_AUTOINIT */
#ifdef SPI0_AUTOINIT
  SPI0_Init();
#endif /* SPI0_AUTOINIT */
#ifdef SPI1_AUTOINIT
  SPI1_Init();
#endif /* SPI1_AUTOINIT */
#ifdef SPI2_AUTOINIT
  SPI2_Init();
#endif /* SPI2_AUTOINIT */
#ifdef SystemControl_AUTOINIT
  SystemControl_Init();
#endif /* SystemControl_AUTOINIT */
#ifdef SysTick_AUTOINIT
  SysTick_Init();
#endif /* SysTick_AUTOINIT */
#ifdef UART0_AUTOINIT
  UART0_Init();
#endif /* UART0_AUTOINIT */
#ifdef UART1_AUTOINIT
  UART1_Init();
#endif /* UART1_AUTOINIT */
#ifdef UART2_AUTOINIT
  UART2_Init();
#endif /* UART2_AUTOINIT */
#ifdef UART3_AUTOINIT
  UART3_Init();
#endif /* UART3_AUTOINIT */
#ifdef UART4_AUTOINIT
  UART4_Init();
#endif /* UART4_AUTOINIT */
#ifdef UART5_AUTOINIT
  UART5_Init();
#endif /* UART5_AUTOINIT */
#ifdef USB0_AUTOINIT
  USB0_Init();
#endif /* USB0_AUTOINIT */
#ifdef USBDCD_AUTOINIT
  USBDCD_Init();
#endif /* USBDCD_AUTOINIT */
#ifdef VREF_AUTOINIT
  VREF_Init();
#endif /* VREF_AUTOINIT */
#ifdef WDOG_AUTOINIT
  WDOG_Init();
#endif /* WDOG_AUTOINIT */
}
Example #13
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  WDOG_Init_TypeDef wInit = WDOG_INIT_DEFAULT;
  int i;

  /* Chip revision alignment and errata fixes */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Watchdog setup - Use defaults, excepts for these :*/
  wInit.em2Run = true;
  wInit.em3Run = true;
  wInit.perSel = wdogPeriod_4k; /* 4k 1kHz periods should give ~4 seconds in EM3 */

  /* Do the demo forever. */

  /* EM0 - 1 sec HFXO  */
  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);
  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000))
  {
    while (1) ;
  }
  Delay(1000);

  /* EM0 - 1 sec HFRCO */
  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000))
  {
    while (1) ;
  }
  Delay(1000);

  /* Turn off systick */
  SysTick_Disable();

  /* EM1 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM1();

  /* EM2 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM2(true);

  /* EM1 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM1();

  /* EM2 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM2(true);

  /* Up and down from EM2 each 10 msec */
  for (i=0; i < 10; i++)
  {
    RTCDRV_Trigger(10, NULL);
    EMU_EnterEM2(true);
    RTCDRV_Delay(10, false);
  }

  /* EM2 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM2(true);

  /* Up and down from EM2 each 2 msec */
  for (i=0; i < 10; i++)
  {
    RTCDRV_Trigger(2, NULL);
    EMU_EnterEM2(true);
  }

  /* EM2 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM2(true);

  /* Up and down from EM2 each msec */
  for (i=0; i < 10; i++)
  {
    RTCDRV_Trigger(1, NULL);
    EMU_EnterEM2(true);
  }

  /* EM2 - 1 sec */
  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM2(true);

  /* Start watchdog */
  WDOG_Init(&wInit);

  /* Enter EM3 - Watchdog will reset chip (and confuse debuggers) */
  EMU_EnterEM3(true);

  /* We will never reach this point */
  return 0;
}
void Peripherals_Init(void)
{
#ifdef NVIC_AUTOINIT
  NVIC_Init();
#endif /* NVIC_AUTOINIT */
#ifdef SIM_AUTOINIT
  SIM_Init();
#endif /* SIM_AUTOINIT */

#ifdef MCM_AUTOINIT
  MCM_Init();
#endif /* MCM_AUTOINIT */
#ifdef PMC_AUTOINIT
  PMC_Init();
#endif /* PMC_AUTOINIT */
#ifdef PORTA_AUTOINIT
  PORTA_Init();
#endif /* PORTA_AUTOINIT */
#ifdef PORTB_AUTOINIT
  PORTB_Init();
#endif /* PORTB_AUTOINIT */
#ifdef PORTC_AUTOINIT
  PORTC_Init();
#endif /* PORTC_AUTOINIT */
#ifdef PORTD_AUTOINIT
  PORTD_Init();
#endif /* PORTD_AUTOINIT */
#ifdef PORTE_AUTOINIT
  PORTE_Init();
#endif /* PORTE_AUTOINIT */

#ifdef ADC0_AUTOINIT
  ADC0_Init();
#endif /* ADC0_AUTOINIT */
#ifdef ADC1_AUTOINIT
  ADC1_Init();
#endif /* ADC1_AUTOINIT */
#ifdef CMP0_AUTOINIT
  CMP0_Init();
#endif /* CMP0_AUTOINIT */
#ifdef CMP1_AUTOINIT
  CMP1_Init();
#endif /* CMP1_AUTOINIT */
#ifdef CRC_AUTOINIT
  CRC_Init();
#endif /* CRC_AUTOINIT */
#ifdef DAC0_AUTOINIT
  DAC0_Init();
#endif /* DAC0_AUTOINIT */
#ifdef DMAMUX_AUTOINIT
  DMAMUX_Init();
#endif /* DMAMUX_AUTOINIT */
#ifdef DMA_AUTOINIT
  DMA_Init();
#endif /* DMA_AUTOINIT */
#ifdef EWM_AUTOINIT
  EWM_Init();
#endif /* EWM_AUTOINIT */
#ifdef FTFA_AUTOINIT
  FTFA_Init();
#endif /* FTFA_AUTOINIT */
#ifdef FTM0_AUTOINIT
  FTM0_Init();
#endif /* FTM0_AUTOINIT */
#ifdef FTM1_AUTOINIT
  FTM1_Init();
#endif /* FTM1_AUTOINIT */
#ifdef FTM2_AUTOINIT
  FTM2_Init();
#endif /* FTM2_AUTOINIT */
#ifdef GPIOA_AUTOINIT
  GPIOA_Init();
#endif /* GPIOA_AUTOINIT */
#ifdef GPIOB_AUTOINIT
  GPIOB_Init();
#endif /* GPIOB_AUTOINIT */
#ifdef GPIOC_AUTOINIT
  GPIOC_Init();
#endif /* GPIOC_AUTOINIT */
#ifdef GPIOD_AUTOINIT
  GPIOD_Init();
#endif /* GPIOD_AUTOINIT */
#ifdef GPIOE_AUTOINIT
  GPIOE_Init();
#endif /* GPIOE_AUTOINIT */
#ifdef I2C0_AUTOINIT
  I2C0_Init();
#endif /* I2C0_AUTOINIT */
#ifdef LLWU_AUTOINIT
  LLWU_Init();
#endif /* LLWU_AUTOINIT */
#ifdef LPTMR0_AUTOINIT
  LPTMR0_Init();
#endif /* LPTMR0_AUTOINIT */
#ifdef PDB0_AUTOINIT
  PDB0_Init();
#endif /* PDB0_AUTOINIT */
#ifdef RCM_AUTOINIT
  RCM_Init();
#endif /* RCM_AUTOINIT */
#ifdef SMC_AUTOINIT
  SMC_Init();
#endif /* SMC_AUTOINIT */
#ifdef SPI0_AUTOINIT
  SPI0_Init();
#endif /* SPI0_AUTOINIT */
#ifdef SystemControl_AUTOINIT
  SystemControl_Init();
#endif /* SystemControl_AUTOINIT */
#ifdef SysTick_AUTOINIT
  SysTick_Init();
#endif /* SysTick_AUTOINIT */
#ifdef UART0_AUTOINIT
  UART0_Init();
#endif /* UART0_AUTOINIT */
#ifdef UART1_AUTOINIT
  UART1_Init();
#endif /* UART1_AUTOINIT */
#ifdef WDOG_AUTOINIT
  WDOG_Init();
#endif /* WDOG_AUTOINIT */
}
Example #15
0
/*
** ===================================================================
**     Method      :  PE_low_level_init (component MC9S08PA16_32)
**
**     Description :
**         Initializes components and provides common register 
**         initialization. The method is called automatically as a part 
**         of the application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /* SCG_C1: FTM2=1,??=0,FTM0=1,??=0,??=0,??=0,MTIM0=1,RTC=1 */
  setReg8(SCG_C1, 0xA3U);               
  /* SCG_C2: ??=0,??=0,DBG=1,NVM=1,IPC=1,CRC=1,??=0,??=0 */
  setReg8(SCG_C2, 0x3CU);               
  /* SCG_C3: ??=0,??=0,SCI1=1,SCI0=1,??=0,SPI0=1,IIC=1,??=0 */
  setReg8(SCG_C3, 0x36U);               
  /* SCG_C4: ACMP=1,??=0,ADC=1,??=0,IRQ=1,??=0,??=0,KBI0=1 */
  setReg8(SCG_C4, 0xA9U);               
  /* Common initialization of the CPU registers */
  /* SYS_SOPT2: TXDME=0 */
  clrReg8Bits(SYS_SOPT2, 0x80U);        
  /* PORT_PTBOE: PTBOE1=1,PTBOE0=0 */
  clrSetReg8Bits(PORT_PTBOE, 0x01U, 0x02U); 
  /* PORT_PTBIE: PTBIE1=0,PTBIE0=1 */
  clrSetReg8Bits(PORT_PTBIE, 0x02U, 0x01U); 
  /* PORT_PTBD: PTBD1=1 */
  setReg8Bits(PORT_PTBD, 0x02U);        
  /* PORT_PTCOE: PTCOE7=1,PTCOE6=0 */
  clrSetReg8Bits(PORT_PTCOE, 0x40U, 0x80U); 
  /* PORT_PTCIE: PTCIE7=0,PTCIE6=1 */
  clrSetReg8Bits(PORT_PTCIE, 0x80U, 0x40U); 
  /* PORT_PTCD: PTCD7=1 */
  setReg8Bits(PORT_PTCD, 0x80U);        
  /* PORT_PTAD: PTAD0=0 */
  clrReg8Bits(PORT_PTAD, 0x01U);        
  /* PORT_PTAPE: PTAPE0=0 */
  clrReg8Bits(PORT_PTAPE, 0x01U);       
  /* PORT_PTAOE: PTAOE0=1 */
  setReg8Bits(PORT_PTAOE, 0x01U);       
  /* PORT_PTAIE: PTAIE0=0 */
  clrReg8Bits(PORT_PTAIE, 0x01U);       
  /* PORT_PTDD: PTDD0=0 */
  clrReg8Bits(PORT_PTDD, 0x01U);        
  /* PORT_PTDPE: PTDPE0=0 */
  clrReg8Bits(PORT_PTDPE, 0x01U);       
  /* PORT_PTDOE: PTDOE0=1 */
  setReg8Bits(PORT_PTDOE, 0x01U);       
  /* PORT_PTDIE: PTDIE0=0 */
  clrReg8Bits(PORT_PTDIE, 0x01U);       
  /* SYS_SOPT3: CLKOE=0,BUSREF=0 */
  clrReg8Bits(SYS_SOPT3, 0x0FU);        
  /* IPC_ILRS9: ILRn3=0,ILRn2=0,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS9, 0x00U);            
  /* IPC_ILRS8: ILRn3=0,ILRn2=0,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS8, 0x00U);            
  /* IPC_ILRS7: ILRn3=0,ILRn2=0,ILRn1=0,ILRn0=2 */
  setReg8(IPC_ILRS7, 0x02U);            
  /* IPC_ILRS6: ILRn3=2,ILRn2=2,ILRn1=2,ILRn0=2 */
  setReg8(IPC_ILRS6, 0xAAU);            
  /* IPC_ILRS5: ILRn3=2,ILRn2=0,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS5, 0x80U);            
  /* IPC_ILRS4: ILRn3=2,ILRn2=0,ILRn1=2,ILRn0=2 */
  setReg8(IPC_ILRS4, 0x8AU);            
  /* IPC_ILRS3: ILRn3=0,ILRn2=0,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS3, 0x00U);            
  /* IPC_ILRS2: ILRn3=0,ILRn2=0,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS2, 0x00U);            
  /* IPC_ILRS1: ILRn3=2,ILRn2=2,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS1, 0xA0U);            
  /* IPC_ILRS0: ILRn3=0,ILRn2=0,ILRn1=0,ILRn0=0 */
  setReg8(IPC_ILRS0, 0x00U);            
  /* IPC_SC: IPCE=1,??=0,PSE=0,PSF=0,PULIPM=0,??=0,IPM=0 */
  setReg8(IPC_SC, 0x80U);               
      /* Initialization of the PORT module */
  /* ### Shared modules init code ... */
  /* ### Asynchro serial "AS_CCTALK" init code ... */
  AS_CCTALK_Init();
  /* ### Free running 8-bit counter "FC_CCTALK" init code ... */
  FC_CCTALK_Init();
  /* ### TimerInt "TI_CCTALK" init code ... */
  TI_CCTALK_Init();
  /* ###  WatchDog "WDOG" init code ... */
  WDOG_Init();
  /* WDOG_CNT: CNT=0xA602 */
  setReg16(WDOG_CNT, 0xA602U);          
  /* WDOG_CNT: CNT=0xB480 */
  setReg16(WDOG_CNT, 0xB480U);          
  /* ### Asynchro serial "AS_DATABUS" init code ... */
  AS_DATABUS_Init();
  /* ### BitIO "LED_RUN" init code ... */
  /* ### BitIO "LED_CCTALK" init code ... */
  /* ### Free running 8-bit counter "FC_DATABUS" init code ... */
  FC_DATABUS_Init();
  /* ### TimerInt "TI_LEDS" init code ... */
  TI_LEDS_Init();
  /* ### IntEEPROM "EEPROM" init code ... */
  EEPROM_Init();
  /* ### Free running 8-bit counter "FC_HOPPER" init code ... */
  FC_HOPPER_Init();
  /* Common peripheral initialization - ENABLE */
  /* FTM0_SC: CLKS=1 */
  clrSetReg8Bits(FTM0_SC, 0x10U, 0x08U); 
  /* FTM2_SC: CLKS=1 */
  clrSetReg8Bits(FTM2_SC, 0x10U, 0x08U); 
  CCR_lock = (byte)0;
  __EI();                              /* Enable interrupts */
}