Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Version 2 PWM timing on Pi 2 #87

Open
jamieboyd opened this issue Aug 22, 2016 · 1 comment
Open

Version 2 PWM timing on Pi 2 #87

jamieboyd opened this issue Aug 22, 2016 · 1 comment

Comments

@jamieboyd
Copy link

I got RPIO.PWM working on the Pi 2 with v2 branch. Thanks for the the update code. One thing I noticed is that the timing is a bit off. With the 20000 microseconds default period, I should get 50 Hz, but I get 44.45 Hz, so the period is off by a factor of 1.25. The pulse widths are similarly longer than they should be.

@jamieboyd
Copy link
Author

I changed the clock divisor in ppm.c from 50 to 45, and re-installed. 49.38 Hz, and pulse timing is much more accurate. In pwm.c:
clk_reg[PWMCLCK_DIV]=0x5A000000 | (50<<12); //set pwm div to 50, giving 10 MHz
change the 50 to 45.
I think the problem is the line above that:
clk_reg[PWM_CLCK_CNTL] = 0x5A000006; // source = PLLD (500 MHZ)
and the constant referred to has changed between Pi versions, so that is selecting a different frequency than previously (450 vs 500). The better fix would be to change the 0x5A000006 to actually select 500Mhz, but where that info is, I don't know.

I think this is too small a thing to do fork and a pull request. So I'll just leave this here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant