How to use hardware PWM

Hello. I’m confused about how can I generate PWM signal using my VIM1 board under Ubuntu-xfce-bionic_Linux-4.9? I want to control it with my C-program, any example will be perfect

I’ve tried wiringPi pwm example:

#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>

int main (void)
{
  if (wiringPiSetup () == -1){
    fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
    exit (1) ;
  }
  printf ("wiringPi PWM test program\n") ;
  pinMode (15, PWM_OUTPUT) ;

  pwmWrite(15, 512);

  for (;;)
  {

  }

  return 0 ;
}

( as gpio readall output said, Physical GPIO pin 35 (PWM_AO_A) is wPi pin number 15 that I used in example above)

And I got an output after running this test program:
warn : _pinMode : Unknown Mode 2
warn : (pwmWrite):THis function is not supported by KHADAS Board.

So is it possible to control PWM pin of VIM1 or not ??

@ClownMik HARDWARE PWM isn’t open in dts. you must open it in dts and compile a new image .

1 Like

Thanks for answer. I’m newbie in making images, may be you can give me some instructions or examples?

@ClownMik OK .

  1. clone fenix in our github.
git clone https://github.com/khadas/fenix.git
  1. source VIM3 in setenv.sh
$ source env/setenv.sh
  1. build kernel
$ make

then reburn it to you board . Becase we have add it to source code , but it don’t support on lastest release firmware . So you don’t need to edit it .

PWM Pin is Pin39

Thanks, Frank. I’ll try

What about PWM pin35? Does VIM1 have 2 hardware pwm (35 and 39) pins that I can use or only 39 is hardware?