while (us)
{
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
--us;
}
}
void SYSCLK_Init (void)
{
int i; // delay counter
OSCXCN = 0x67; // start external oscillator with
// 18.432MHz crystal
for (i=0; i < 256; i++) ; // Wait for osc. to start up
while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
OSCICN = 0x88; // select external oscillator as SYSCLK
// source and enable missing clock
// detector
// OSCICN = 0x07; file://interal 16MHZ
}
#define PRT0CF P0MDOUT
#define PRT1CF P1MDOUT
#define PRT2CF P2MDOUT
void PORT_Init (void)
{
XBR0 = 0x07; // Enable SMBus, SPI0, and UART0
XBR1 = 0x00;
XBR2 = 0x44; // Enable crossbar and weak pull-ups
EMI0CF = 0x27;
EMI0TC = 0x21;
P74OUT = 0xFF;
P0MDOUT = 0x15;
P1MDOUT |= 0x3C; //P1.2-P1.5 推挽输出
P1 &= 0xc3; //P1.2-P1.5=0
}
void SPI0_Init (void)
{
SPI0CFG = 0x07; // data sampled on 1st SCK rising edge
// 8-bit data words
SPI0CFG|=0xC0; //CKPOL =1;