-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clock freqs #10
Comments
Hi Klamath233, Thanks, for trying my stuff out, I hope it helps you out =D Yes the clock frequencies are configurable, there is a clock divisor that can get different speeds, from a chosen clock source. Good luck with your Raspberry Pi projects. |
I've read the same pages, but I can only find a table demonstrating the spread effect of different MASH parameters mentions the number 650 MHz. There isn't a relation between this number and any PLL output frequency. I've done an experiment on my Pi 3 trying to figure out the frequency of PLLC. I set GPCLK0 to get the source from PLLC and the divisor to be 1000. I then connect GPIO4(ALT0) to a logical analyzer, and the waveform shows a frequency of 1 MHz, indicating the PLLC output is actually 1000 MHz. Could you tell me where the official document states the 650MHz so that I can research more deeply? Thanks! |
Ah I think I see what might be the case, on the original oldest R-Pi, I think PLLC was 650MHz, as this was the 1:1 speed with the main CPU, as the R-Pi 2 & 3 came out with GHz speeds, this must have been raised along with the faster CPU clock speeds, & with over clocking would change too. |
My pleasure. I have some following-up questions.
|
For point 2, I think they've moved the left channel to GPIO 41. I tried turning GPIO 41 to ALT0 instead of GPIO 45 and got output from both channel. |
Hi Klamath233, Thanks for all your testing, I have re-opened this issue, until I fix the stereo output on my R-Pi3 demo, many thanks for telling me about that. As for point 1, I just used my pc playing at the same time, to find a number that matched 44.1KHz sound output, so I just used my hearing for that. Anyway, thanks for all your help. |
My basic thought is a group of equations: range = pwm_freq / sample_rate .....(1) As an example: Now, assume we are using 500 MHz PLLD: Also, to support fractional divider, we need to turn on 1-stage MASH in the clock control register. This bugged me all the day today. To summary, in this case, I don't think mono/stereo should affect these numbers, but I need to test the mono case as well. |
Hi Klamath233, Looks good to me, thanks for all your testing. Please let me know how you get on with your tests. |
It goes pretty well as for 12-bit 44100Hz and 8-bit 44100Hz. The clock numbers are irrelevant to stereo/mono; the reason you are getting twice as fast in mono is that you only write a word to the FIFO once while you have both channels enabled. This way, one word goes to the right while next word goes to the left channel. Since the two words are modulated simultaneously in different channels, the sound goes twice as fast. If we write the same word twice to the FIFO, the playback rate is back to normal. Another question, when you set the clock source, you say I really appreciate this demo you make because it would take me days to get this working as they move the PWM operation logic to the VC – there would be no reference for me to look at even in the Linux kernel. (And you know how poorly the documents for this board are written :/) |
Hi Klamath233, Cool findings thanks for telling me. I made these demos specifically for people like you, took me a long time to get anything to work lol! Thanks again for all your testing. |
@Klamath233 were you able to get the sound demos working in the end on rpi 3b? I have them working but with white noise at the end of the loop. Thanks! |
I tried applying all of these changes on my RPi 3B here but this didn't fix things for me. The sample plays, but does not repeat, because it cuts out before any repeat occurs. Sometimes the display is updated too, but not always. I also noticed that for me, it only works without the In any case, I'm not quite sure how to fix the audio. This is the last thing I need to fix for my PiFox port to RPi 3, as everything else seems to be working now. Many thanks for any advice you can give! I should add, I'm booting over TFTP, just in case that affects the ARM initialisation in any way, with the latest firmware. |
Hi Peter, I think: And: Amazing Tutorials!!! Congratulations. |
hi ivancerra, Thanks =D |
I have no explanation, but the original version of Sound/PWM/12Bit/44100Hz/Stereo/DMA and Sound/PWM/12Bit/44100Hz/Stereo/CPU are both working for me now on my rpi3b, despite there being no changes to the source since I previously noticed the issue. Firmware fix? 🤷♂️
UPDATE: just read #10 (comment) @PeterLemon based on the information from @ivancerra and @Klamath233 should I expect these examples not to play correctly on a rpi3b? I really can't work out why I had the issue before, but it seems to be gone now! :-) |
I've created PR #21 for fixing the GPIO 45 -> GPIO 41 on rpi3. |
Raspberry raw sound pwn dma, Explained https://github.com/ivancerra/RBRawSound Thanks peter! |
This looks great @ivancerra, many thanks! |
Hi Peter,
First of all, thank you for this great collection of bare metal projects. I notice that in the audio subdirectory, different files are using different clock sources, and you label their frequency in comments. However, their values are different from what's listed here http://pinout.xyz/pinout/gpclk. Are these clock frequencies configurable?
The text was updated successfully, but these errors were encountered: