Hi forum,
I'm trying to figure out how Linux maps the eHRPWM channels to the sysfs interface, accessible via /sys/class/pwm. I have enabled the A and B pins for each PWM, and set the status for &ehrpwm0 through &ehrpwm5 to "okay". When Linux boots, I can see the following after cd /sys/class/pwm:
# pwd /sys/class/pwm # ls pwmchip0 pwmchip1 pwmchip11 pwmchip3 pwmchip5 pwmchip7 pwmchip9 # cd pwmchip0 # ls device export npwm power subsystem uevent unexport # ls device driver modalias power subsystem driver_override of_node pwm uevent # cat device/modalias of:NpwmT<NULL>Cti,am654-ecapCti,am3352-ecap # cd .. # cat pwmchip1/device/modalias of:NpwmT<NULL>Cti,am654-ehrpwmCti,am3352-ehrpwm # cat pwmchip3/device/modalias of:NpwmT<NULL>Cti,am654-ehrpwmCti,am3352-ehrpwm # cat pwmchip5/device/modalias of:NpwmT<NULL>Cti,am654-ehrpwmCti,am3352-ehrpwm # cat pwmchip7/device/modalias of:NpwmT<NULL>Cti,am654-ehrpwmCti,am3352-ehrpwm # cat pwmchip9/device/modalias of:NpwmT<NULL>Cti,am654-ehrpwmCti,am3352-ehrpwm
From this I can figure out that pwmchip0 is controlled by eCAP, whereas pwmchip1, 3, 5, 7, and 9 are eHRPWM.
How can I figure out which pwmchipX is connected to eHRPWM0, 1, 2, 3, 4, and 5?
Also, can anyone provide an example of how to create the two PWM channels for an eHRPWM, set the duty cycle and period, and then enable the PWM?
I think that it's something like:
# Which eHRPWM is this? cd /sys/class/pwm/pwmchipX # Create pwm0 and pwm1 echo 0 > export echo 1 > export # Set up pwm0 cd pwm0 # What are the units for duty_cycle and period??? echo NNN > duty_cycle echo MMM > period # Set active high polarity echo 1 > polarity # Turn on the PWM echo 1 > enable
Is this the correct approach? If so, what are the allowed values for duty_cycle and period?
Thanks very much for your help - there has to be a simple answer to this!
Scott