Ich versuche, I2C Bit Banging zu kommunizieren mit OLED in PIC 18F4520 zu implementieren. Es funktioniert gut ohne "Uhr-Stretching", aber wenn ich "Uhr-Stretching" setze, funktioniert es nicht. Und auch ich habe versucht mit dem "Clock Stretching" -Block vor und nach dem ACK-Puls zu arbeiten, beide funktionieren nicht. Was ist mit meinem Clock-Stretching falsch?I2C Bit schlagen mit Clock Stretching funktioniert nicht
void send_packet(){
/* Soft_I2C_Start(); //Here its working fine
Soft_I2C_Write(0x78);
Soft_I2C_Write(tx_packet[0]);
Soft_I2C_Write(tx_packet[1]);
Soft_I2C_Stop();*/
unsigned char i,temp=0x78; //Slave Address with write permission
ASDA=1; //Start Condition
ASCL=1;
delay_ms(1);
ASDA=0;
ASCL=0;
for(i=0;i<8;i++){
if(temp & 0x80){
ASDA=1;
}
else{
ASDA=0;
}
temp=temp<<1;
ASCL=1;
ASCL=0;
}
ASCL=1; //Acknowledgment Pulse
ASCL=0;
while(PORTC.RC4==0); //Clock Stretching
for(i=0;i<8;i++){
if(tx_packet[0] & 0x80){
ASDA=1;
}
else{
ASDA=0;
}
tx_packet[0]=tx_packet[0]<<1;
ASCL=1;
ASCL=0;
}
ASCL=1; //Acknowledgment Pulse
ASCL=0;
while(PORTC.RC4==0); //Clock Stretching
for(i=0;i<8;i++){
if(tx_packet[1] & 0x80){
ASDA=1;
}
else{
ASDA=0;
}
tx_packet[1]=tx_packet[1]<<1;
ASCL=1;
ASCL=0;
}
ASCL=1; //Acknowledgment Pulse
ASCL=0;
while(PORTC.RC4==0); //Clock Stretching
ASCL=1; //Stop Condition
ASDA=1;
}
danke. . . Ich korrigiere diesen Fehler, aber es funktioniert immer noch nicht. . .Ich aktualisierte den bearbeiteten Code –
Yup es funktioniert. . . Das Problem ist mit der Taktdehnungslinie. . Ich habe das und seine Arbeit entfernt. . . Aber ich habe immer noch Zweifel, was ist falsch mit Uhr Stretching? –
Ich habe meine Frage auch aktualisiert –