我用的gz16的芯片,设置用中断来接收PC机发送的数据,可以好象没有产生中断,不知道是为什么,下面是我得程序。
#include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */
unsigned char temp=0; unsigned char rxdata=0; void MCU_init(void); /* Device initialization function declaration */
void main(void) {
unsigned char temp,rxdata; temp=0; rxdata=0; PTD=0; DDRD=0xff;//output /* include your code here */ CONFIG1=0x39; CONFIG2=0x10;
SCBR=0x30;//baud rate 9600 SCC1=0x40;//enable SCI,no parity test,8bit data
SCC2=0x2C;//enable transmitter and receiver SCC3=0x00; SCC2_SCTIE=0; EnableInterrupts; /* enable interrupts */ /* include your code here */
for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave this function */ }
interrupt void SCRF(void) { temp=SCS1; rxdata=SCDR; if(rxdata==0x55) PTD_PTD0=1; else PTD_PTD2=1; // SCC2_SCTIE=1; }
|