Shop OBEX P1 Docs P2 Docs Learn Events
Source Code for pwm_set() — Parallax Forums

Source Code for pwm_set()

Looking for source code for pwm_set()

Is this an assembly routine? or is it written in C somewhere?

Comments

  • The code is in the Simple Libraries under utility.
    void pwm_set(int pin, int channel, int tHigh)
    {
      if(!channel)
      {
        ctra = NCO_PWM_1;
        ctra |= pin;
        ticksA = tHigh * st_usTicks;
      }
      else
      {
        ctrb = NCO_PWM_1;
        ctrb |= pin;
        ticksB = tHigh * st_usTicks;
      }
    }
    

    Mike
  • Thanks for the direction.

    I eventually found the source code at:
    C:\Program Files (x86)\SimpleIDE\Workspace\Learn\Simple Libraries\Utility\libsimpletools\source
    in pwm.c file.

    Is this pwm.c file compiled into my program when I use pwm_set()?

    If then any accidental edit would be a problem.
  • This is compiled as a library object and only the complete source modules are included by reference if you use them.

    In SimpleIDE there is a tab labeled Linker that has a library option that generates the compiled library file. This gets merged into your code when you use it.

    If you change the source to this function, not advised build your own, you need to compile it with the hammer so that it updates that library object.

    Mike
Sign In or Register to comment.