设置了初始化和中断,如果进入RTC中断的话外部的LED应该是可以闪烁的。
void Init(void)
{
unsigned char cklf;
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
TMOD = 0x20; // Timer1 8bit auto reload
TR1 = 1; // Start timer1
P0_ALT |= 0x06; // Select alternate functions on pins P0.1 P0.2
P0_DIR |= 0x02; // P0.1 (RxD) is input
SPICLK = 5; // SPI clock
SPI_CTRL = 0x02; // Connect internal 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 RTC_init(void)
{
TICK_DV=0x05;
while((REGX_CTRL&0x10)!=0){;}
REGX_MSB = 0x01;
REGX_LSB = 0xff;
REGX_CTRL= 0x0A;
}
bit led="0";
void RTC_ISR(void) interrupt 12
{
WDTI =0;
led=!led;
P04=led;
}
void main(void)
{
P0_ALT = 0x00;
P0_DIR = 0xAF;
Init();
EWDI=1;
EA = 1;
Delay100us(255);
for (;
{
}
}
文章评论(0条评论)
登录后参与讨论