Hi,
The field "thread" has to be NULL this is intentional, it is the osalThreadSuspendTimeoutS() function that writes in it. If it hangs it is because the thread is not resumed after suspending itself.
Giovanni
I2C on OLIMEX-STM32-LCD (STM32F103ZE) Topic is solved
- Giovanni
- Site Admin
- Posts: 14461
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
-
- Posts: 25
- Joined: Fri Nov 06, 2020 3:28 pm
- Location: Salivonky City
- Has thanked: 4 times
- Been thanked: 4 times
Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)
Found the problem. It doesn't work with DMA. I made some small fix related to disabling DMA and it works. I suppose DMA isn't configured properly.
Giovanni, I think it has sense to add those changes to repo.
Giovanni, I think it has sense to add those changes to repo.
Code: Select all
diff --git a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
index 57ee6db..10d29cc 100644
--- a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
@@ -941,7 +941,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -955,7 +957,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
}
return msg;
@@ -1041,8 +1045,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -1056,8 +1062,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial/os/hal/ports/STM32/LLD/I2Cv1$ git diff hal_i2c_lld.c > hal_i2c_lld^C
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial/os/hal/ports/STM32/LLD/I2Cv1$ Giovanni^C
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial/os/hal/ports/STM32/LLD/I2Cv1$
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$ git diff hal_i2^C
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$ git diff os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
diff --git a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
index 57ee6db..10d29cc 100644
--- a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
@@ -941,7 +941,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -955,7 +957,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
}
return msg;
@@ -1041,8 +1045,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -1056,8 +1062,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$ git diff os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c > hal_i2c_lld.patch
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$
cat hal_i2c_lld.patch
diff --git a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
index 57ee6db..10d29cc 100644
--- a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
@@ -941,7 +941,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmarx);
+#endif
return MSG_TIMEOUT;
}
@@ -955,7 +957,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmarx);
+#endif
}
return msg;
@@ -1041,8 +1045,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif
return MSG_TIMEOUT;
}
@@ -1056,8 +1062,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif
}
return msg;
- Giovanni
- Site Admin
- Posts: 14461
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
- Giovanni
- Site Admin
- Posts: 14461
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)
Hi,
In I2Cv1 there is no STM32_I2C_USE_DMA, are we talking about a customized driver?
Giovanni
In I2Cv1 there is no STM32_I2C_USE_DMA, are we talking about a customized driver?
Giovanni
- Giovanni
- Site Admin
- Posts: 14461
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Who is online
Users browsing this forum: No registered users and 3 guests