Open AdamLaurie opened 2 years ago
Thanks, looks like a good starting point. Where did you find a documentation of the frequencies ? That would be good to include in a comment.
i got the frequencies through experimentation and observation via oscilloscope, not via documentation. if i move the code back to line 105 compilation fails, as per commit comments. i would love to be more helpful but, again, as per commit comments, i'm not a c++ guy so i have no clue. sorry!
Hi, I found this code from librpitx which is a radio frequency transmitter library for raspberry pi and the engine of rpitx.
I don't have any pi 4 device so I couldn't test it, but I think it might be helpful information. The pi 4 support in rpitx is still in beta mode, but it looks like a lot of people are using it so I think it can be trusted to some extent.
i got the frequencies through experimentation and observation via oscilloscope, not via documentation.
In the code I found, the frequency of the regular oscillator for pi 4 seems to be 54000000 which is close to your observation.
(XOSC_FREQUENCY
is 54000000 and pi_is_2711
is true for pi 4 from the code)
I couldn't figure out the other frequency values (pllc, plld, hdmi) from the code. But I'm sure you guys can figure it out (by running it, for example).
if i move the code back to line 105 compilation fails, as per commit comments. i would love to be more helpful but, again, as per commit comments, i'm not a c++ guy so i have no clue. sorry!
BTW if you move the definition of enum RaspberryPiModel
and add a forward declaration of GetPiModel
function before GPIO::StartClock
, you can avoid the compilation error.
for example:
// We are not interested in the _exact_ model, just good enough to determine
// What to do.
enum RaspberryPiModel {
PI_MODEL_1,
PI_MODEL_2,
PI_MODEL_3,
PI_MODEL_4
};
// just a forward declaration
static RaspberryPiModel GetPiModel();
// BCM2835-ARM-Peripherals.pdf, page 105 onwards.
double GPIO::StartClock(double requested_freq) {
// ...
}
as per my commit comments i'm not a c++ guy so feel free to treat this as a starting point and do a nicer job, but it does seem to work! :)