网上只能查到
S2CON &= ~S2RI; //Clear receive interrupt flag
这个只是判断他是否接收到了数据
想要让他接收到1 应该怎么判断?
这是官网提供的例程代码,直接用if或者switch语句判断sbuf就可以了,
把P0口改成接收数据的缓存如temp,详细的参考STC-SPI软件自带例程:
/*---------------------------- UART2 interrupt service routine ----------------------------*/ void Uart2() interrupt 8 using 1 { if (S2CON & S2RI) { S2CON &= ~S2RI; //Clear receive interrupt flag P0 = S2BUF; //P0 show UART data P2 = (S2CON & S2RB8);//P2.2 show parity bit } if (S2CON & S2TI) { S2CON &= ~S2TI; //Clear transmit interrupt flag busy = 0; //Clear transmit busy flag } }