Mr_driver 发表于 2013-5-10 15:53 
你的中断函数贴上来看下 - void __irq IicInt(void)
- {
- U32 iicSt,i;
-
- rSRCPND = BIT_IIC; //Clear pending bit
- rINTPND = BIT_IIC;
- iicSt = rIICSTAT;
-
- if(iicSt & 0x8){} //When bus arbitration is failed.
- if(iicSt & 0x4){} //When a slave address is matched with IICADD
- if(iicSt & 0x2){} //When a slave address is 0000000b
- if(iicSt & 0x1){} //When ACK isn't received
- switch(_iicMode)
- {
- case POLLACK:
- _iicStatus = iicSt;
- break;
- case RDDATA:
- if((_iicDataCount--)==0)
- {
- _iicData[_iicPt++] = rIICDS;
-
- rIICSTAT = 0x90; //Stop MasRx condition
- rIICCON = 0xaf; //Resumes IIC operation.
- Delay(1); //Wait until stop condtion is in effect.
- //Too long time. //The pending bit will not be set after issuing stop condition.
- break;
- }
- _iicData[_iicPt++] = rIICDS; //The last data has to be read with no ack.
- if((_iicDataCount)==0)
- rIICCON = 0x2f; //Resumes IIC operation with NOACK.
- else
- rIICCON = 0xaf; //Resumes IIC operation with ACK
- break;
- case WRDATA:
- if((_iicDataCount--)==0)
- {
- rIICSTAT = 0xd0; //Stop MasTx condition
- rIICCON = 0xaf; //Resumes IIC operation.
- Delay(1); //Wait until stop condtion is in effect.
- //The pending bit will not be set after issuing stop condition.
- break;
- }
- rIICDS = _iicData[_iicPt++]; //_iicData[0] has dummy.
- for(i=0;i<10;i++); //for setup time until rising edge of IICSCL
-
- rIICCON = 0xaf; //resumes IIC operation.
- break;
- case SETRDADDR:
- if((_iicDataCount--)==0)
- break; //IIC operation is stopped because of IICCON[4]
- rIICDS = _iicData[_iicPt++];
- for(i=0;i<10;i++); //For setup time until rising edge of IICSCL
- rIICCON = 0xaf; //Resumes IIC operation.
- break;
- default:
- break;
- }
- }
|