#include <reg9e5.h> #define POWER 3 // 0=min power...3 = max power #define HFREQ 0 // 0=433MHz, 1=868/915MHz #define CHANNEL 106 // Channel number: f(MHz) = (422.4+CHANNEL/10)*(1+HFREQ) unsigned char SpiReadWrite(unsigned char b); void UartInit(void); void NrfInit(void); void Default_Init(void); #define uchar unsigned char uchar incoming,outgoing,lastinchar; void main(void) { UartInit(); NrfInit(); while(1); } void UartInit(void) { TH1 = 243; // 19200@16MHz (when T1M=1 and SMOD=1) CKCON |= 0x10; // T1M=1 (/4 timer clock) PCON = 0x80; // SMOD=1 (double baud rate) SCON = 0x52; // Serial mode1, enable receiver IE=0x10; TMOD &= ~0x30; TMOD |= 0x20; // Timer1 8bit auto reload TR1 = 1; // Start timer1 P0_ALT |= 0x06; // Alternate functions on pins P0.1-2 P0_DIR |= 0x02; // P0.1 (RxD) is input } void NrfInit(void) { unsigned char cklf; SPICLK = 0; // Max SPI clock SPI_CTRL = 0x02; // Connect SPI controller to Radio // switch to 16MHz clock: RACSN = 0; SpiReadWrite(RRC | 0x09); cklf = SpiReadWrite(0) | 0x04; RACSN = 1; RACSN = 0; SpiReadWrite(WRC | 0x09); SpiReadWrite(cklf); RACSN = 1; } void serint(void) interrupt 4 { if(RI) { incoming=SBUF; RI=0; } if (TI) { SBUF=incoming; TI=0; } } 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; } can help me to solve how to add "interrupt" into this program provided above. So that when i input a ASCII code through serial port, the output is the same ASCII code thanks
In the sample folder
u mean which sample example? can give a more detail answer? thanks
Maybe it's just a language barrier, but the place to look is always in the 'Support' section: http://www.keil.com/support/default.asp Once you're there, look at "Application Notes" and "Example Programs and Utilities"; also try the "File Download Area"