Skip to content

port to pi4#19

Open
AdamLaurie wants to merge 3 commits into
hzeller:masterfrom
AdamLaurie:master
Open

port to pi4#19
AdamLaurie wants to merge 3 commits into
hzeller:masterfrom
AdamLaurie:master

Conversation

@AdamLaurie

Copy link
Copy Markdown

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! :)

…seems to select regular oscillator, see comments in code).

apologies for moving code around - i'm not a c++ guy and that was the easiest way to get it to compile. i also don't understand
why i'm getting warnings! enjoy!
Comment thread gpio.cc
}


// BCM2835-ARM-Peripherals.pdf, page 105 onwards.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the diff small, can you move this block back to around line 105 ?

@hzeller

hzeller commented Jan 21, 2022

Copy link
Copy Markdown
Owner

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.

@AdamLaurie

Copy link
Copy Markdown
Author

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!

@pjueon

pjueon commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

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).

@pjueon

pjueon commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

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) {
// ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants