TS-7250-V3 FPGA PWM: Difference between revisions
From embeddedTS Manuals
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
The TS-7250-V3 includes a PWM core that supports 10-bit duty/period, a 79.2mhz input clock, and | The TS-7250-V3 includes a PWM core that supports 10-bit duty/period, a 79.2mhz input clock, and 12 values of input clock shift. | ||
Linux supports this API through the /sys/ interface. | Linux supports this API through the /sys/ interface. | ||
Line 18: | Line 18: | ||
<!-- | <!-- | ||
79.2mhz clock, divisor 0, 1023 bits | |||
1000000000/((1000000000/(79200000 >> 0)*1023)) | |||
1000000000/(79200000 >> 0)*1023 | |||
(79200000 >> 0) / 1023 | |||
--> | --> | ||
{|class=wikitable | {|class=wikitable | ||
! Divisor | ! Divisor | ||
! Frequency (hz) | ! PWM Input Frequency (hz) | ||
! Max Period (ns) | ! Max Period (ns) | ||
! Max Period (hz) | |||
|- | |- | ||
| 0 | | 0 | ||
| 79200000 | | 79200000 | ||
| 12917 | | 12917 | ||
| 77419 | |||
|- | |- | ||
| 1 | | 1 | ||
| 3960000 | | 3960000 | ||
| 25833 | | 25833 | ||
| 38710 | |||
|- | |- | ||
| 2 | | 2 | ||
| 1980000 | | 1980000 | ||
| 51667 | | 51667 | ||
| 19355 | |||
|- | |- | ||
| 3 | | 3 | ||
| 990000 | | 990000 | ||
| 103333 | | 103333 | ||
| 9677 | |||
|- | |- | ||
| 4 | | 4 | ||
| 495000 | | 495000 | ||
| 206667 | | 206667 | ||
| 4839 | |||
|- | |- | ||
| 5 | | 5 | ||
| 247500 | | 247500 | ||
| 413333 | | 413333 | ||
| 2419 | |||
|- | |- | ||
| 6 | | 6 | ||
| 123750 | | 123750 | ||
| 826667 | | 826667 | ||
| 1210 | |||
|- | |- | ||
| 7 | | 7 | ||
| 61875 | | 61875 | ||
| 1653333 | | 1653333 | ||
| 605 | |||
|- | |- | ||
| 8 | | 8 | ||
| 30937 | | 30937 | ||
| 3306667 | | 3306667 | ||
| 302 | |||
|- | |- | ||
| 9 | | 9 | ||
| 15468 | | 15468 | ||
| 6613333 | | 6613333 | ||
| 151 | |||
|- | |- | ||
| 10 | | 10 | ||
| 7734.38 | | 7734.38 | ||
| 13226795 | | 13226795 | ||
| 76 | |||
|- | |- | ||
| 11 | | 11 | ||
| 3867 | | 3867 | ||
| 26453932 | | 26453932 | ||
| | | 38 | ||
|} | |} | ||
If period is set to one of these values, the full 10 bits of duty cycle is available. Past that, the Linux API will use the closest available value. | If period is set to one of these values, the full 10 bits of duty cycle is available. Past that, the Linux API will use the closest available value. | ||
This core is located at 0x500001a8. | This core is located at 0x500001a8. |
Revision as of 17:13, 5 October 2021
The TS-7250-V3 includes a PWM core that supports 10-bit duty/period, a 79.2mhz input clock, and 12 values of input clock shift.
Linux supports this API through the /sys/ interface.
# Export PWM channel 0
echo 0 > /sys/class/pwm/pwmchip0/export
# Set Period to 20ms
echo 20000000 > /sys/class/pwm/pwmchip0/pwm0/period
# Set duty cycle to 5ms
echo 5000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
# Enable PWM
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
The Linux PWM API will attempt to arrive at the exact period at the cost of the duty cycle resolution. For the most expressive duty cycle, target a frequency that is an exact shift of the input clock. Linux's API maxes out the max period/duty as 4294967295ns
Divisor | PWM Input Frequency (hz) | Max Period (ns) | Max Period (hz) |
---|---|---|---|
0 | 79200000 | 12917 | 77419 |
1 | 3960000 | 25833 | 38710 |
2 | 1980000 | 51667 | 19355 |
3 | 990000 | 103333 | 9677 |
4 | 495000 | 206667 | 4839 |
5 | 247500 | 413333 | 2419 |
6 | 123750 | 826667 | 1210 |
7 | 61875 | 1653333 | 605 |
8 | 30937 | 3306667 | 302 |
9 | 15468 | 6613333 | 151 |
10 | 7734.38 | 13226795 | 76 |
11 | 3867 | 26453932 | 38 |
If period is set to one of these values, the full 10 bits of duty cycle is available. Past that, the Linux API will use the closest available value.
This core is located at 0x500001a8.
Offset | Bits | Description |
---|---|---|
0x0 | 15:2 | Reserved |
1 | Inversed (0 = idle high, duty cycle low), (1 = idle low, duty cycle high) | |
0 | Enabled | |
0x2 | 15:10 | Reserved |
9:0 | Period | |
0x4 | 15:10 | Reserved |
9:0 | Duty Cycle | |
0x6 | 15:10 | Reserved |
4:0 | shift (Clock frequency = 79200000 / (1 >> shift)) |