|
主函数如下,为什么调试时经常跑到第二个 while ( NIRQ == 1);时过不去,有时也会卡到第一while,但有时却跑的很好两个while都能过去,而且通信正常,不知道各位有没有遇到过这种情况还望各位高手指点一下,这个问题已经困扰我很久了!!!
void main(void)
{
U8 ItStatus1,ItStatus2;
U16 delay;
U8 length,temp8;
U8 payload[10];
//Initialize the MCU:
// - set IO ports for the Software Development board
// - set MCU clock source
// - initialize the SPI port
// - turn off LEDs
MCU_Init();
/* ======================================================== *
* Initialize the Si443x ISM chip *
* ======================================================== */
//Turn on the radio by pulling down the PWRDN pin
SDN = 0;
//Wait at least 15ms befory any initialization SPI commands are sent to the radio
// (wait for the power on reset sequence)
for (temp8=0;temp8<15;temp8++)
{
for(delay=0;delay<10000;delay++);
}
//read interrupt status registers to clear the interrupt flags and release NIRQ pin
ItStatus1 = SpiReadRegister(0x03); //read the Interrupt Status1 register
ItStatus2 = SpiReadRegister(0x04); //read the Interrupt Status2 register
//SW reset
SpiWriteRegister(0x07, 0x80); //write 0x80 to the Operating & Function Control1 register
//wait for POR interrupt from the radio (while the nIRQ pin is high)
while ( NIRQ == 1);
//read interrupt status registers to clear the interrupt flags and release NIRQ pin
ItStatus1 = SpiReadRegister(0x03); //read the Interrupt Status1 register
ItStatus2 = SpiReadRegister(0x04); //read the Interrupt Status2 register
//wait for chip ready interrupt from the radio (while the nIRQ pin is high)
while ( NIRQ == 1);
//read interrupt status registers to clear the interrupt flags and release NIRQ pin
ItStatus1 = SpiReadRegister(0x03); //read the Interrupt Status1 register
ItStatus2 = SpiReadRegister(0x04); //read the Interrupt Status2 register
。。。。。。。。。。。 |
|