How to Enable and Control PWM on AML-S905X-CC

AML-S905X-CC Le Potato has 5 available hardware PWM multiplex over 6 pins. The hardware PWMs are grouped in chip pairs accessible via pwm0 and pwm1.

  • AO_A AO_B on c8100550
  • A on c1108550
  • E F on c11086c0

You cannot enable overlapping overlays within the grouped pair. This means you can not individually enable pwm-e and pwm-f. You have to enable pwm-ef to have both running at the same time.

In terms of pin routing:

  • AO_A on Pin 11 controlled via c8100550 pwm0
  • AO_B on Pin 12 or 13 controlled via c8100550 pwm1
  • E on Pin 32 controlled via c11086c0 pwm0
  • A on Pin 33 controlled via c1108550 pwm0
  • F on Pin 35 controlled via c11086c0 pwm1

For AO_A on pin 11, you must move the jumper for 2J1 to the edge of the board from the stock jumper position to connect the GPIO to the 40 pin header pin 11.

There are 9 dto combinations to select from:

  • pwm-ao-6 on Pin 11 and 12
  • pwm-ao-9 on Pin 11 and 13
  • pwm-ao-a on Pin 11
  • pwm-ao-b-6 on Pin 12
  • pwm-ao-b-9 on Pin 13
  • pwm-a on Pin 33
  • pwm-e on Pin 32
  • pwm-ef on Pin 32 and 35
  • pwm-f on Pin 35

The Linux kernel interface can be accessed via sysfs.

sudo ldto enable pwm-{x} # replace x with one of the dtos in list above
ls -al /sys/class/pwm # see the pwmchip{n} to hardware mapping
echo {0,1} > /sys/class/pwm/pwmchip{n}/export
echo 1000000 > /sys/class/pwm/pwmchip{n}/pwm{n}/period
echo 500000 > /sys/class/pwm/pwmchip{n}/pwm{n}/duty_cycle
echo 1 > /sys/class/pwm/pwmchip{n}/pwm{n}/enable

Can you give an example for how to control a servo motor plugged into pin 11?

I assume pin 11 will have {n} = 0. How do we:

  1. enable pin 11
  2. set frequency to 50hz
  3. change duty cycle
  4. turn off pin (so there aren’t fluctuations) until we enable it again

Check the updated post. Please run sudo apt update && sudo apt dist-upgrade before trying the dtos. They were just added.

  1. sudo ldto enable pwm-ao-a
  2. The period is in nanoseconds per the kernel interface. So if you want a 1KHz signal, you need to put 1000000.
  3. Duty cycle is also in nanoseconds so if you want a certain %, multiply it by the period.
  4. echo 1 > enable

I moved the jumper over one pin to the edge, updated my board, ran commands below and wasnt able to get anything from my servo. i am connected to gpio pin 11, power on pin 4, and ground on pin 6. i used multiple brand new servos to rule out defected hardware. any thoughts?

sudo ./ldto enable pwm-ao-a
sudo ./ldto active
ls -al /sys/class/pwm
echo 1 > /sys/class/pwm/pwmchip0/export
echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/period
echo 500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable

update: Just kidding i looked over the " AO_A on Pin 11 controlled via c8100550 pwm0" part. after echoing 0 instead of 1 to /sys/class/pwm/pwmchip0/export, that took care of the problem. Any thoughts on how to reverse the direction?

1 Like

There should be a file called polarity and you can echo a 0 or 1 and it should work.