В апп ноте написано:
Цитата
The procedure is as follows:
1) Master tries to assert a Logic 1 on the SDA line
2) Master still sees a Logic 0 and then generates a clock
pulse on SCL (1-0-1 transition)
3) Master examines SDA. If SDA = 0, go to Step 2; if
SDA = 1, go to Step 4
4) Generate a STOP condition
Note that this process may need to be repeated because
the cleared SDA line may have been cleared for the next
bit, which was a 1. There may be some concern about the
effect this additional clocking and STOPping has on other
peripherals. There is no adverse effect; other slaves are
not paying attention due to the fact that they have not
been addressed. Only the slave that had the interrupted
message will respond to the clocks.
1) Master tries to assert a Logic 1 on the SDA line
2) Master still sees a Logic 0 and then generates a clock
pulse on SCL (1-0-1 transition)
3) Master examines SDA. If SDA = 0, go to Step 2; if
SDA = 1, go to Step 4
4) Generate a STOP condition
Note that this process may need to be repeated because
the cleared SDA line may have been cleared for the next
bit, which was a 1. There may be some concern about the
effect this additional clocking and STOPping has on other
peripherals. There is no adverse effect; other slaves are
not paying attention due to the fact that they have not
been addressed. Only the slave that had the interrupted
message will respond to the clocks.
Сделал так:
Код
GPIO_PinAFConfig(GPIO_SCL, GPIO_PinSource_SCL, 0); //GPIO_AF_I2Cx
GPIO_PinAFConfig(GPIO_SDA, GPIO_PinSource_SDA, 0); //GPIO_AF_I2Cx
//Configure and initialize the GPIOs
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SCL;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_SCL, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SDA;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_Init(GPIO_SDA, &GPIO_InitStructure);
i=0;
while((GPIO_ReadInputDataBit(GPIO_SDA,GPIO_Pin_SDA)==0)&&(i<20)){
GPIO_ResetBits(GPIO_SCL,GPIO_Pin_SCL);
delay10us(1);
GPIO_SetBits(GPIO_SCL,GPIO_Pin_SCL);
delay10us(1);
i++;
}
sEE_LowLevel_Init();
GPIO_PinAFConfig(GPIO_SDA, GPIO_PinSource_SDA, 0); //GPIO_AF_I2Cx
//Configure and initialize the GPIOs
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SCL;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIO_SCL, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SDA;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_Init(GPIO_SDA, &GPIO_InitStructure);
i=0;
while((GPIO_ReadInputDataBit(GPIO_SDA,GPIO_Pin_SDA)==0)&&(i<20)){
GPIO_ResetBits(GPIO_SCL,GPIO_Pin_SCL);
delay10us(1);
GPIO_SetBits(GPIO_SCL,GPIO_Pin_SCL);
delay10us(1);
i++;
}
sEE_LowLevel_Init();
Подскажите, где может быть ошибка в реализации? И как можно инициировать сбой, чтобы отладить данный код?