新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PIC單片機(jī)之I2C(從模式)

PIC單片機(jī)之I2C(從模式)

作者: 時(shí)間:2013-05-30 來(lái)源:網(wǎng)絡(luò) 收藏

while(PIR1bits.SSP1IF == 0)

{

timercounter--;

if(timercounter==0)

{

return;

}

}//waiting for ~ACK

SSP1IF = 0;

if(SSP1CON2bits.ACKSTAT == 1)

{

return ; //NOACK

}

else

{

i2c_counter++;//ACK

}

}

SSP1IF = 0;

}

}

void i2c_salve_interrupt_rx()//master writer

{

unsigned char rx_status;

unsigned char Temp;

unsigned int timercounter;

rx_status=false;

Temp=SSP1STAT;

Temp = 0x2D;

if(Temp==0x09)//Write operation,last byte was an address,buffer is full

{

SSP1IF = 0;

i2c_address = SSP1BUF;

timercounter=while_delay;

while(PIR1bits.SSP1IF == 0)

{

timercounter--;

if(timercounter==0)

{

return ;

}

}//waiting for send ~ACK

SSP1IF = 0;

word_address = SSP1BUF;

return ;

}

if(Temp==0x29)//Write operation,last byte was data,buffer is full

{

SSP1IF=0;

Register[word_address]=SSP1BUF;

word_address++;

if(word_address>=RX_BUF_LEN)

{

word_address=0;

}

}

}

單片機(jī)相關(guān)文章:單片機(jī)教程


單片機(jī)相關(guān)文章:單片機(jī)視頻教程


單片機(jī)相關(guān)文章:單片機(jī)工作原理



上一頁(yè) 1 2 3 下一頁(yè)

關(guān)鍵詞: PIC單片機(jī) I2C 從模式

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉