Coder Social home page Coder Social logo

Comments (7)

joan2937 avatar joan2937 commented on August 16, 2024

At the moment changing one channel will cause a glitch on the other channel if it is also transmitting PWM.

I'll have a look at the datasheet to see if the glitch can be prevented.

from pigpio.

joan2937 avatar joan2937 commented on August 16, 2024

I changed the title to more accurately reflect the actual behaviour.

I have been more intelligent in the way I set up the channels which means this should no longer happen.

The fix will be in V52 (when it is released).

from pigpio.

nachoplus avatar nachoplus commented on August 16, 2024

Ok. I'll be waiting for V52. I'll give you feedback when I try it.
Thank you very much! I really apreciate your fast support!

from pigpio.

joan2937 avatar joan2937 commented on August 16, 2024

If you want to give it a try you could apply the following patch to V51 of pigpio.c.

Save as patch.txt and then

patch pigpio.c patch.txt

--- pigpio.c-V51    2016-04-26 17:42:48.539091253 +0100
+++ pigpio.c    2016-04-26 16:51:39.450230475 +0100
@@ -25,7 +25,7 @@
 For more information, please refer to <http://unlicense.org/>
 */

-/* pigpio version 51 */
+/* pigpio version 52 */

 /* include ------------------------------------------------------- */

@@ -1144,6 +1144,7 @@
 static uint32_t reportedLevel = 0;

 static int waveClockInited = 0;
+static int PWMClockInited = 0;

 static volatile gpioStats_t gpioStats;

@@ -7551,6 +7552,7 @@
    DBG(DBG_STARTUP, "");

    waveClockInited = 0;
+   PWMClockInited = 0;

    clock_gettime(CLOCK_REALTIME, &libStarted);

@@ -8958,6 +8960,7 @@
       stopHardwarePWM();
       initClock(0); /* initialise secondary clock */
       waveClockInited = 1;
+      PWMClockInited = 0;
    }

    p = rawWaveCBAdr(waveInfo[wave_id].topCB);
@@ -9194,6 +9197,7 @@
       stopHardwarePWM();
       initClock(0); /* initialise secondary clock */
       waveClockInited = 1;
+      PWMClockInited = 0;
    }

    dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
@@ -11413,11 +11417,16 @@
       old_PWM_CTL = pwmReg[PWM_CTL] &
          (PWM_CTL_PWEN1 | PWM_CTL_MSEN1 | PWM_CTL_PWEN2 | PWM_CTL_MSEN2);

-      pwmReg[PWM_CTL] = 0;
+      if (!PWMClockInited)
+      {
+         pwmReg[PWM_CTL] = 0;

-      myGpioDelay(10);
+         myGpioDelay(10);

-      initHWClk(CLK_PWMCTL, CLK_PWMDIV, CLK_CTL_SRC_PLLD, 2, 0, 0);
+         initHWClk(CLK_PWMCTL, CLK_PWMDIV, CLK_CTL_SRC_PLLD, 2, 0, 0);
+
+         PWMClockInited = 1;
+      }

       if (pwm == 0)
       {

from pigpio.

nachoplus avatar nachoplus commented on August 16, 2024

Clean compilation and works perfectly! This was a blocking issue for me and now I can continue with my project!
Thank you very much!

from pigpio.

joan2937 avatar joan2937 commented on August 16, 2024

Okay. Unless I hear otherwise I'll close this as an issue when I release V52.

from pigpio.

joan2937 avatar joan2937 commented on August 16, 2024

V52 released.

from pigpio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.