main.c

来自「44b0代码」· C语言 代码 · 共 63 行

C
63
字号
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"

static int mt0cnt=0;
static int ledstatus=0;

void __irq timer0_int(void)
{
   rI_ISPC=BIT_TIMER0;
   Uart_Printf("let's begin \n");
   mt0cnt++;
   	
   if (mt0cnt>100)
   {
       Uart_Printf("in 1 second \n");
       mt0cnt=0;
	Led_Display(ledstatus);
	ledstatus=(~ledstatus)&0x7;
   }
   else ;
   return ;
}

void init_timer0(void)
{
    rINTMSK=~(BIT_GLOBAL|BIT_TIMER0|BIT_EINT3);
    pISR_TIMER0=(U32) timer0_int; 
    rTCFG0=0x00000064;    //timer0 prescaler=200
    rTCFG1=0x00000004;     //timer0 divider value=1/32; (all interrupt)
    rTCNTB0=(unsigned int)(MCLK/(rTCFG0&0x000000ff)/32/100 );   //40*1000000/200/32/100==63   (10ms)
    rTCON=0x00a;
    rTCON=0x009;
   // rINTCON=0x5;
}

void closetimer0(void)
{    
    rINTMSK=~(BIT_TIMER0)|rINTMSK;
}





void Main(void)
{
    rSYSCFG=CACHECFG;   // Using 8KB Cache//

    Port_Init();
    
    Led_Display(0x0);

    Uart_Init(0,115200);
    Delay(10);
    Uart_Select(0); //Select UART0

    Uart_Printf("\nHello,FS44B0X!");
    init_timer0();
    while(1); 
       
}

⌨️ 快捷键说明

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