acassis commented on a change in pull request #4239:
URL: https://github.com/apache/incubator-nuttx/pull/4239#discussion_r677551236



##########
File path: arch/risc-v/src/esp32c3/esp32c3_tim.c
##########
@@ -341,19 +426,35 @@ static void esp32c3_tim_getcounter(FAR struct 
esp32c3_tim_dev_s *dev,
 static void esp32c3_tim_setcounter(FAR struct esp32c3_tim_dev_s *dev,
                                   uint64_t value)
 {
-  uint64_t low_64 = value & LOW_32_MASK;
-
-  /* Get only the low 22 bits. */
-
-  uint64_t high_64 = (value >> SHIFT_32) & LOW_22_MASK;
   struct esp32c3_tim_priv_s *priv;
   DEBUGASSERT(dev);
   priv = (FAR struct esp32c3_tim_priv_s *)dev;
 
-  /* Set the counter value */
+  if (priv->id == ESP32C3_SYSTIM)
+    {
+      uint64_t low_64 = value & LOW_32_MASK;
+      uint64_t high_64 = (value >> SHIFT_32) & LOW_20_MASK;
+
+      /* Set the counter 1 value */
 
-  putreg32((uint32_t)low_64, TIMG_T0LOADLO_REG(priv->id));
-  putreg32((uint32_t)high_64, TIMG_T0LOADHI_REG(priv->id));
+      putreg32((uint32_t)low_64, SYS_TIMER_SYSTIMER_UNIT1_LOAD_LO_REG);
+      putreg32((uint32_t)high_64, SYS_TIMER_SYSTIMER_UNIT1_LOAD_HI_REG);
+
+      /* Synchronize */
+
+      putreg32(SYS_TIMER_TIMER_UNIT1_LOAD_M,
+               SYS_TIMER_SYSTIMER_UNIT1_LOAD_REG);
+    }
+  else
+    {
+      uint64_t low_64 = value & LOW_32_MASK;
+      uint64_t high_64 = (value >> SHIFT_32) & LOW_22_MASK;

Review comment:
       I think it is better to keep low_64 and high_64 inside the function 
because it will be used one way or another




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to