written at 22:02 by faberman
IMX.6 PWM Configuration

To experiment with different PWM configurations to reduce display flickering I wrote this little tool. It reads and writes the IMX.6 registers and bypasses the Linux drivers.

USAGE

$ pwmconfig -h Usage: pwmconfig [-r] ([-f val] [-d <val>]) | ([-p <val>] [-s <val>] [-P <val>] [-S <val>]) <pwmid>] -r show the register contents Automatic PWM configuration: -f set the PWM frequency for the given PWM -d set the duty cycle, 0..100 Manual PWM configuration: -p set the period value for the given PWM -s set the sample value for the given PWM -P sets the clock prescaler, 0..4095 -S sets the clock source, 0..3

Example: To set the PWM clock of PWM 1 to 15 kHz and the duty cycle to 50%, run

$ pwmconfig -f 15000 -d 50 1

To read the registers of a PWM peripheral, run

$ pwmconfig -r 1 *** PWM1 Registers PWMCR 0x03c20001 FWM FIFO Water Mark : 0 STOPEN Stop Mode Enable : 1 DOZEN Doze Mode Enable : 1 WAITEN Wait Mode Enable : 1 DBGEN Debug Mode Enable : 1 BCTR Byte Data Swap Control : 0 HCTR Half-word Data Swap Control : 0 POUTC PWM Output Configuration : 0 CLKSRC Select Clock Source : 2 PRESCALER Counter Clock Prescaler: 0 SWR Software Reset : 0 REPEAT Sample Repeat : 0 EN PWM Enable : 1 PWMSR 0x00000038 FWE FIFO Write Error Status : 0 CMP Compare Status : 1 ROV Roll-over Status : 1 FE FIFO Empy Status Bit : 1 FIFOAV FIFO Available : 0 PWMIR 0x00000000 CIE Compare Interrupt Enable : 0 RIE Roll-over Interrupt Enable : 0 FIE FIFO Empty Interrupt Enable : 0 PWMSAR 0x00001104 SAMPLE: 0x1104 (4356) PWMPR 0x00001102 PERIOD: 0x1102 (4354) PWMCNR 0x0000042d COUNT: 0x0cea (3306) *** PWM1 Configuration Period : 4354 Duty cycle : 4356/4354 = 100% PWM clock rate: 66000000 Hz PWM prescaler : 1 PWM frequency : 15158 Hz

SOURCE

pwmconfig_v1.tgz