?? test.c
字號(hào):
/*------------------------------------------------------------------------------
TEST.C: ISD51 Demo for classic 8051 devices like Philips 89C51RD2/89C66x
Copyright 2002 - 2003 Keil Software, Inc.
------------------------------------------------------------------------------*/
#include <reg9e5.h>
#include <intrins.h>
#include <absacc.h>
#include "ISD51.h"
sbit LED_FLAG=P0^4;
void delay(void);
unsigned char j;
unsigned char code testarray[] = "Some Text";
#if 0 // uncomment this function to verify serial communication
/*
* Test Function: verify serial communication with HyperTerminal
*/
void delay(void)
{
long i;
i = 0x800;
while(i--);
}
void TestSerial (void)
{
char c = 'A';
TI = 1;
while (1)
{
if (RI)
{
c = SBUF;
RI = 0;
}
while (!TI);
TI = 0;
delay();
SBUF = c;
}
}
#endif
unsigned char SpiReadWrite(unsigned char b)
{
EXIF &= ~0x20; // Clear SPI interrupt
SPI_DATA = b; // Move byte to send to SPI data register
while((EXIF & 0x20) == 0x00) // Wait until SPI hs finished transmitting
;
return SPI_DATA;
}
void main (void)
{
unsigned int i, tmp;
P0_DIR = 0x02; // P0.1 (RxD) is an input
P0_ALT = 0x06; // Select alternate functions on pins P0.1 and P0.2
T2CON = 0x34; /* Use Timer 2 as baudrate generator */
RCAP2H = 0xFF;
RCAP2L = 0xF7; /* 57600 baud @ 16MHz */
SCON = 0x50; /* enable serial uart & receiver */
LED_FLAG=0;
SPICLK = 1;
SPI_CTRL = 0x02; // Connect internal SPI controller to Radio
// Switch to 16MHz clock: //config nRF9E5 clock
RACSN = 0;
SpiReadWrite(RRC | 0x09);
tmp = SpiReadWrite(0) | 0x0C;
RACSN = 1;
RACSN = 0;
SpiReadWrite(WRC | 0x09);
SpiReadWrite(tmp);
RACSN = 1;
LED_FLAG=1;
EA = 1; /* Enable global interrupt flag */
TestSerial (); // uncomment this function to verify serial communication
#if 0 // init ISD51 and start user program until the uVision2 Debugger connects
ISDinit (); // initialize uVision2 Debugger and continue program run
#endif
#if 0 // init ISD51 and wait until the uVision2 Debugger connects
ISDwait (); // wait for connection to uVision2 Debugger
#endif
for (i = 0; i < sizeof (testarray); i++)
{
j = testarray[i];
}
while (1)
{
#if 1 // init ISD51 only when the uVision2 Debugger tries to connect
ISDcheck(); // initialize uVision2 Debugger and continue program run
#endif
_nop_();
_nop_();
LED_FLAG=0;
_nop_();
_nop_();
LED_FLAG=1;
_nop_();
_nop_();
#if 0 // you may use ISDbreak when ISD51 is started with ISDcheck or ISDwait
ISDbreak (); // hard coded stop (breakpoint)
#endif
_nop_();
_nop_();
_nop_();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -