[En-Nut-Discussion] TwMasterTransact is blocked
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Tue Sep 11 14:02:57 CEST 2012
>>>>> "CAMBON," == CAMBON, Olivier <Olivier.CAMBON at astrium.eads.net> writes:
CAMBON,> The call to TwMasterTransact never returns (with or without
CAMBON,> timeout in parameter). But the CPU is still alive. All the
CAMBON,> other threads with higher or lower priorities are alive.
CAMBON,> I did not checked the electrical lines with a scope. But I can
CAMBON,> see that all the slaves are alive.
CAMBON,> Maybe there were some errors during the transaction. But I
CAMBON,> think the call should go in timeout in this case.
Please try appended patch. This makes NutTwiMasterTranceive honor the tmo
value even if the BUS is always busy. Maybe the magic 63 ms wait should be
made substantial lower. If it helps for you, check your bus for a contention
or something similar.
At least the code compiles for me ;-)
CAMBON,> -----Original Message----- From:
CAMBON,> en-nut-discussion-bounces at egnite.de
Please don't full quote. It clutters the archives
Bye
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
diff --git a/nut/arch/avr/dev/twif.c b/nut/arch/avr/dev/twif.c
index 7b91057..1088cdc 100644
--- a/nut/arch/avr/dev/twif.c
+++ b/nut/arch/avr/dev/twif.c
@@ -520,6 +520,9 @@ int NutTwiMasterTranceive(NUTTWIBUS *bus, uint8_t sla, const void *txdata, uint1
while(icb->tw_if_busy) {
NutSleep(63);
+ if (tmo < 63)
+ return -1;
+ tmo -= 63;
}
NutEnterCritical();
/*
More information about the En-Nut-Discussion
mailing list