My use-case is needing to drive two differential DC motors on a mobile robot where the motor drivers are controlled via PWM where the motor speed is adjusted by a 0…+5v input signal (using level-shifters on the GPIO header).
On my Nano 2GB I have PWM-0 and PWM-2 available to use and I wish to control them via a kernel driver that will write directly to the PWM Controller registers (ie: PWM_CONTROLLER_PWM_CSR__0) :
root@elroy:~/dev/pwm# cat /sys/kernel/debug/pwm
platform/70110000.pwm, 1 PWM device
pwm-0 (pwm-regulator ): requested enabled period: 2500 ns duty: 0 ns polarity: normal
platform/7000a000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (pwm-regulator ): requested period: 8000 ns duty: 1440 ns polarity: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 (pwm-fan ): requested enabled period: 45334 ns duty: 0 ns polarity: normal
The problem is, how can I start both PWM’s in a synchronized way so that they both fire-off at exactly the same time? I can achieve this on the Raspberry Pi BCM2835 which has a register that has bits that can be OR’d together to enable multiple PWM outputs, simultaneously.
Is there something like this available on the Tegra X1 ?
Alternatively, should I perhaps try this method, or something similar? :-
- Enable the SWR_PWM_RST (set to 1) on CLK_RST_CONTROLLER_RST_DEVICES_L_SET_0 to reset / “stop” the PWM’s.
- Disable the SET_CLK_ENB_PWM (set to 0) on CLK_RST_CONTROLLER_CLK_ENB_L_SET_0 to “stop” the PWM clocks.
- configure and ENABLE PWM-0 and PWM-2 via PWM_CONTROLLER_PWM_CSR_0_0 and PWM_CONTROLLER_PWM_CSR_2_0 registers
- Clear the CLR_CLK_ENB_PWM (set to 1) on CLK_RST_CONTROLLER_CLK_ENB_L_CLR_0 to “start” the PWM clocks.
- Clear the CLR_PWM_RST (set to 1) on CLK_RST_CONTROLLER_RST_DEV_L_CLR_0 to start / “enable” the PWM’s
Would this be a way that I could get PWM-0 and PWM-2 to start simultaneously (synchronized) and would this be best-practice?
Thanks very much!