📄 sysinit.c
字号:
//***************************************************************
// ARM BOOT ROUTE VER1.0@0x0C000000 for 44B0X release
// bjwork2007@gmail.com
// chenjun @ 2005-6-10
//***************************************************************
#include "..\inc\NXP_ARM.h"
#include "..\inc\usart.h"
#include "..\inc\sysinit.h"
#include "..\inc\common.h"
unsigned int MCLK;
unsigned int PCLK;
void SetPll(unsigned char M, unsigned char P)
{
unsigned int MCLK_Value;
unsigned int TempFV;
unsigned int i;
unsigned char VPBDIV;
switch(P)
{
case 0:i=1;break;
case 1:i=2;break;
case 2:i=4;break;
case 3:i=8;break;
default:i=2;break;
}
MCLK_Value = EXT_OSC_CLK * M;
if ((MCLK_Value > 75000000) || (MCLK_Value < 10000000))
{
puts("Set PLL is no correct!MCLK no changed!\n");
return;
}
else
{
TempFV = MCLK_Value * 2 * i;
if((TempFV < 156000000) || (TempFV > 320000000))
{
puts("Set PLL is no correct!MCLK no changed!\n");
return;
}
else
{
rPLLCON = 0x1;
if(MCLK_Value > 40000000)
{
VPBDIV = 2;
PCLK = MCLK_Value >> 1;
}
else
{
VPBDIV = 1;
PCLK = MCLK_Value;
}
rVPBDIV = VPBDIV;
rPLLCFG = ((M - 1) | (P << 5));
rPLLFEED = 0xaa;
rPLLFEED = 0x55;
while((rPLLSTAT & (1 << 10)) == 0);
rPLLCON = 0x3;
rPLLFEED = 0xaa;
rPLLFEED = 0x55;
Delay(0x10000);
MCLK = MCLK_Value;
return;
}
}
}
void PortInit(void)
{
//***************************** PORT 0 GROUP ******************************
// 15 14 13 12 11 10 9 8
// 00 P0.15 P0.14 P0.13 P0.12 P0.11 P0.10 P0.9 P0.8
// 01 RI1 CD1 DTR1 DSR1 CTS1 RTS1 RXD1 TXD1
// 10 EINT2 EINT1 MATCH1.1 MATCH1.0 CAP1.1 CAP1.0 PWM6 PWM4
// 11 -- -- -- -- -- -- EINT3 --
// VAL: 10 10 00 00 00 00 01 01
// RE_PULSE2 RE_PULSE1 P0.13 P0.12 P0.11 P0.10 RXD1 TXD1
//-------------------------------------------------------------------------
// 7 6 5 4 3 2 1 0
// 00 P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0
// 01 SSEL0 MOSI0 MISO0 SCK0 SDA SCL RXD0 TXD0
// 10 PWM2 CAP0.2 MATCH0.1 CAP0.1 MATCH0.0 CAP0.0 PWM3 PWM1
// 11 EINT2 -- -- -- EINT1 -- EINT0 --
// VAL: 00 00 00 00 00 00 01 01
// P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 RXD0 TXD0
//*************************************************************************
rPINSEL0 = 0xA0050005;
//***************************** PORT 0 GROUP ******************************
// 31 30 29 28 27 26 25 24
// 00 -- P0.30 P0.29 P0.28 P0.27 -- P0.25 P0.24
// 01 -- AIN3 AIN2 AIN1 AIN0 -- -- --
// 10 -- EINT3 CAP0.3 CAP0.2 CAP0.1 -- -- --
// 11 -- CAP0.0 MATCH0.3 MATCH0.2 MATCH0.1 -- -- --
// VAL: 00 01 01 01 01 00 00 00
// -- RM_R RM_L RM_3V3 Bais -- P0.25 AMP_SD
//-------------------------------------------------------------------------
// 23 22 21 20 19 18 17 16
// 00 P0.23 P0.22 P0.21 P0.20 P0.19 P0.18 P0.17 P0.16
// 01 -- -- PWM5 MATCH1.3 MATCH0.0 CAP1.3 CAP1.2 EINT0
// 10 -- CAP0.0 -- SSEL1 MOSI1 MISO1 SCK1 MATCH0.2
// 11 -- MATCH0.0 MATCH1.3 EINT3 MATCH1.3 MATCH1.3 MATCH1.2 CAP0.2
// VAL: 00 00 00 00 00 00 00 01
// RM_TEST AM_ANT LCD_BL RM_nINT P0.19 P0.18 P0.17 RE_PUSH
//*************************************************************************
rPINSEL1 = 0x15400001;
//************************ PORT 1,2,3 GROUP ************************
// BIT31..28:----
// BIT27..25:CTRLAB: 111 [A23:2 are address line]
// BIT24 :CTRLP301 : 1 [P3.1 is an address line]
// BIT23 :CTRLP300 : 0 [P3.0 is a GPIO Pin]
// BIT22 :CTRLP231 : 0 [P2.31 is a GPIO Pin]
// BIT21 :CTRLP230 : 0 [P2.30 is a GPIO Pin]
// BIT20 :CTRLP229_28 : 0 [P2.29..28 is GPIOs]
// BIT19..18:--
// BIT17..16:CTRLP324 : 01 [P3.24 is nCS3 pin]
// BIT15..14:CTRLP325 : 01 [P3.25 is nCS2 pin]
// BIT13 :CTRLP323 : 0 [P3.23 is an address line]
// BIT12 :-
// BIT11 :CTRLP326 : 1 [P3.26 is nCS1 pin]
// BIT10..9 :--
// BIT8 :CTRLP327 : 1 [P3.27 is nWE pin]
// BIT7 :CTRLP328 : 0 [P3.28 is a GPIO pin]
// BIT6 :CTRLP329 : 0 [P3.29 is a GPIO pin]
// BIT5..4 :CTRLPDBP : 01 [P1.1(OE),P2.7..0(D7..0),P2.15..8(D15..8),P2.27..16(GPIO),
// P2.29..28(GPIO),P2.30(GPIO),P2.31(GPIO),P1.0(CS0),P3.31(BLS0),
// P3.30(BLS1),P3.28(GPIO),P3.29(GPIO)]
// BIT3 :GPIO/TRACE : 0 [Pins P1.25..16 are used as GPIO port]
// BIT2 :GPIO/DEBUG : 1 [Pins P1.31..26 are used as JTAGDebug port]
// BIT1..0 :--
//***************************************************************
rPINSEL2 = 0x0f014914;
rSCS = 0x0; //use VPB GPIO
rIO0DIR = 0x036e3cfc; //0 is input;1 is output
rIO0PIN = 0x01000000;
rIO1DIR = 0x03ff0000;
rIO1PIN = 0x00fd0000;
rIO2DIR = 0xfff00000;
rIO2PIN = 0x00000000;
rIO3DIR = 0x30000001;
rIO3PIN = 0x00000000;
SetPll(6,1);
ConsoleInit();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -