I2C on OLIMEX-STM32-LCD (STM32F103ZE) Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)  Topic is solved

Postby Giovanni » Thu Mar 18, 2021 12:30 pm

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

Tuxford
Posts: 25
Joined: Fri Nov 06, 2020 3:28 pm
Location: Salivonky UA
Has thanked: 4 times
Been thanked: 4 times

Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)

Postby Tuxford » Thu Mar 18, 2021 1:35 pm

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.

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;

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)

Postby Giovanni » Thu Mar 18, 2021 1:37 pm

Hi,

Moving this to "bug reports".

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)

Postby Giovanni » Sat Apr 09, 2022 9:11 am

Hi,

In I2Cv1 there is no STM32_I2C_USE_DMA, are we talking about a customized driver?

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: I2C on OLIMEX-STM32-LCD (STM32F103ZE)

Postby Giovanni » Tue Apr 26, 2022 9:29 am

Closing.


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 13 guests