I would like to use my own clock settings (integer, fractional, and mash) instead on the one that is autogenerated by the function gpioHardwareClock. Is it possible to do that with pigpio ?

If not what how do i modify the library so that i can do so ? I know the library calls this function to start the clock but i have no way of accessing it?

static void initHWClk
   (int clkCtl, int clkDiv, int clkSrc, int divI, int divF, int MASH)
   DBG(DBG_INTERNAL, "ctl=%d div=%d src=%d /I=%d /f=%d M=%d",
      clkCtl, clkDiv, clkSrc, divI, divF, MASH);

   /* kill the clock if busy, anything else isn't reliable */

   if (clkReg[clkCtl] & CLK_CTL_BUSY)
         clkReg[clkCtl] = BCM_PASSWD | CLK_CTL_KILL;
      while (clkReg[clkCtl] & CLK_CTL_BUSY);

   clkReg[clkDiv] = (BCM_PASSWD | CLK_DIV_DIVI(divI) | CLK_DIV_DIVF(divF));


   clkReg[clkCtl] = (BCM_PASSWD | CLK_CTL_MASH(MASH) | CLK_CTL_SRC(clkSrc));


   clkReg[clkCtl] |= (BCM_PASSWD | CLK_CTL_ENAB);

1 Answer 1


There is nothing stopping you from making a change to your local copy of the source code, recompiling, and relinking.

Make the changes in the pigpio source directory (to pigpio.c) and then type make followed by sudo make install.

  • that function is already at pigpio.c, but im getting an error that initHWClk is undefined when compiling.
    – DrakeJest
    Commented Apr 6, 2021 at 14:21
  • Please add the compiler output to your question.
    – joan
    Commented Apr 6, 2021 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.