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

📄 lib_c.c

📁 ARMS3C44B0X的起动代码
💻 C
字号:
#include "R44b0.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

#include "lib.h"

static int delayLoopCount=400;
#define DELAY 10000
void Delay(int time)
// time=0: adjust the Delay function by WatchDog timer.
// time>0: the number of loop time
// 100us resolution.
{
    int i,adjust=0;
    if(time==0)
    {
	time=200;
	adjust=1;
	rWTCON=((MCLK/1000000-1)<<8)|(2<<3);  // 1M/64,Watch-dog,nRESET,interrupt disable
	rWTDAT=0xffff;
	rWTCNT=0xffff;	 
	rWTCON=((MCLK/1000000-1)<<8)|(2<<3)|(1<<5); // 1M/64,Watch-dog enable,nRESET,interrupt disable 
    }
    for(;time>0;time--)
	for(i=0;i<delayLoopCount;i++);
    if(adjust==1)
    {
	rWTCON=((MCLK/1000000-1)<<8)|(2<<3);
	i=0xffff-rWTCNT;   //  1count/16us?????????
	delayLoopCount=8000000/(i*64);	//400*100/(i*64/200)   
    }
}

/************************* PORTS ****************************/

void Port_Init(void)
{    //CAUTION:Follow the configuration order for setting the ports. 
    // 1) setting value 
    // 2) setting control register 
    // 3) configure pull-up resistor.  

    //PORT A GROUP
    //GPA9 ADDR23 ADDR22 ADDR21 ADDR20 ADDR19 ADDR18 ADDR17 ADDR16 ADDR0		      
    //  0,    1,     1,    1,     1,     1,     1,      1,     1,    1
    rPCONA=0x1ff;	
    rPDATA=0x0;
    //PORT B GROUP
    //GPB10  GPB9 nGCS3 nGCS2 nGCS1 GPB5 GPB4 nSRAS nSCAS SCLK SCKE
    //  0,    0,    1,	1,    1,    0,    0,	1,    1,   1,   1	
    rPCONB=0x1Cf;
    
    //PORT C GROUP
    //IISLRCK  IISD0 IISDI IISCLK VD7 VD6 VD5 VD4 nXDACK1 nXDREQ1 GPC10 GPC11 TXD1 RXD1 GPC14 GPC15
    //All input
    //  11      11    11    11    11  11   11  11   11      11     01	01     11   01   01    01
    //rPDATC=0x8400;
    //rPCONC=0x5F5FFFFF;	
    //rPUPC=0x33ff;	//should be enabled	
    rPDATC=0xffff;	//All I/O Is High
    rPCONC=0x0f05ff55;	
    rPUPC=0x30f0;	//PULL UP RESISTOR should be enabled to I/O
    
   
    //PORT D GROUP
    //VFRAME VM VLINE VCLK VD3 VD2 VD1 VD0
    //    10,10,   10,	10, 10,	10, 10,	10  
    rPCOND=0xaaaa;	
    rPUPD=0xff;

	//PORT E GROUP
	//PE0:FOUT, PE1:TxD0, PE2:RxD0, GPE3, GPE4, GPE5,GPE6,GPE7, CODECLK   
	//    10       10,      10,    01  , 01,   01,  01,  01,   10
	rPCONE=0x2B;//0x2552A;	
	rPUPE=0x00;	//0xff;	
	rPDATE=0xff;
	
	//PORT F GROUP
	//IICSCL IICSDA  nWAIT nXBACK0 nXDREQ0 GPF5 GPF6 GPF7 GPF8 
	//  10     10      10    10      10     0    0    0    0
	rPCONF=0x9256A;//0x2A;
	rPUPF=0xff;

    //PORT G GROUP
    //EINT0 EINT1 EINT2 EINT3 GPG4 GPG5 GPG6 GPG7
    //	  0x0
    //  11      11   11     11   01   01   01   01
    rPDATG=0x0;
    rPCONG=0x55FF;
    rPUPG=0xf;
    
    rSPUCR=0x7;  //pull-up disable
    rEXTINT=0x22222022;  //All EINT[7:0] will be falling edge triggered.
}
void Led_Display(int LedStatus)
{
	//PC1,PC2,PC3 High available
    rPDATC=(rPDATC & 0x1f1) | ((LedStatus & 0x7)<<1);
}
void Test_Led(void)
{

     // Delay(0);  //calibrate Delay()
    Led_Display(1);
    Delay(DELAY);  //calibrate Delay()
    Led_Display(3);
    Delay(DELAY);
    Led_Display(7);
    Delay(DELAY);

    Led_Display(3);
    Delay(DELAY);
    Led_Display(1);
    Delay(DELAY);
    Led_Display(0);
    Delay(DELAY);
   // Uart_Printf("\n start, press any key to return \n");
}

⌨️ 快捷键说明

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