⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 文件功能 44binit.s----中断初始化
💻 C
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"

////////////////////////////////////////
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);      
void HaltDabort(void);

void __irq Wdt_Int(void);
volatile int isWdtInt;

void Main(void)
{
    unsigned char *src, *dst;
    int i;
    unsigned int memSum;

    rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
    ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif

    Isr_Init();
    Port_Init();
    Uart_Init(0,115200);
    Uart_Select(0);
    Delay(0);  //calibrate Delay()
    Led_Display(7);
    Delay(1000);  //calibrate Delay()
    Led_Display(0);
    Delay(5000);  //calibrate Delay()
    Led_Display(7);

    rINTMSK=~(BIT_GLOBAL|BIT_WDT);
    pISR_WDT=(unsigned)Wdt_Int;
    isWdtInt=0;
	
    rWTCON=((MCLK/1000000-1)<<8)|(3<<3)|(1<<2);  //  t_watchdog = 1/66/128, interrupt enable
    rWTDAT=8448/4;
    rWTCNT=8448/4;
    rWTCON=rWTCON|(1<<5);   // 1/40/128,interrupt 

    while(isWdtInt!=10);

    rWTCON=((MCLK/1000000-1)<<8)|(3<<3)|(1);  //   1/66/128, reset enable
    Uart_Printf("\nI will restart after 2 sec!!!\n");
    rWTCNT=8448*2;
    rWTCON=rWTCON|(1<<5);   // 1/40/128,interrupt 
    while(1);
    rINTMSK|=BIT_GLOBAL;
}

void __irq Wdt_Int(void)
{
    rI_ISPC=BIT_WDT;
    Uart_Printf("%d ",++isWdtInt);
}



/******************************************************************/

void Isr_Init(void)
{
    U32 i;
    
    pISR_UNDEF=(unsigned)HaltUndef;
    pISR_SWI  =(unsigned)HaltSwi;
    pISR_PABORT=(unsigned)HaltPabort;
    pISR_DABORT=(unsigned)HaltDabort;
    
     for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
    {
	*((volatile unsigned *)i)=0xEA000000+0x1FFE;
    }

    rINTCON=0x5;	  // Non-vectored,IRQ enable,FIQ disable    

    rINTMOD=0x0;	  // All=IRQ mode
    rINTMSK|=BIT_GLOBAL|BIT_EINT3;	  // All interrupt is masked.
}


void HaltUndef(void)
{
    Uart_Printf("Undefined instruction exception!!!\n");
    while(1);
}

void HaltSwi(void)
{
    Uart_Printf("SWI exception!!!\n");
    while(1);
}

void HaltPabort(void)
{
    Uart_Printf("Pabort exception!!!\n");
    while(1);
}

void HaltDabort(void)
{
    Uart_Printf("Dabort exception!!!\n");
    while(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -