Nerdy notes » History » Version 1

Giulio Moro, 2015-07-28 06:48 PM

1 1 Giulio Moro
h1.  Nerdy notes 
2 1 Giulio Moro
3 1 Giulio Moro
This is just a collection of notes from/for developers. Sometimes it is also useful to know the mistakes that others made so not to waste your time when we already wasted ours. Note that if you attempt any of the hacks here it might void your warranty. Do not do this, please.
4 1 Giulio Moro
5 1 Giulio Moro
h2. Media clock on the Beaglebone Black with BeagleRT cape
6 1 Giulio Moro
7 1 Giulio Moro
The media clock is hardcoded to 44.1kHz. This can be changed by changing the PLL values in I2c_codec::startAudio.
8 1 Giulio Moro
Current settings are as follows
9 1 Giulio Moro
<pre>
10 1 Giulio Moro
writeRegister(0x02, 0x00)	// Codec sample rate register: fs_ref / 1
11 1 Giulio Moro
writeRegister(0x03, 0x91)	// PLL register A: PLL enabled, Q=2, P=1
12 1 Giulio Moro
writeRegister(0x04, 0x1C)	// PLL register B: J= 7
13 1 Giulio Moro
writeRegister(0x05, 0x52)	// PLL register C: D=5264, part 1
14 1 Giulio Moro
writeRegister(0x06, 0x40)	// PLL register D: D=5264, part 2
15 1 Giulio Moro
</pre>
16 1 Giulio Moro
Notes:
17 1 Giulio Moro
Q is not relevant as PLL is disabled 
18 1 Giulio Moro
J range is 1 to 63
19 1 Giulio Moro
D range is 0 to 9999
20 1 Giulio Moro
P range is 1 to 8
21 1 Giulio Moro
R range is 1 to 16
22 1 Giulio Moro
K=J.D=7.5264
23 1 Giulio Moro
P=1
24 1 Giulio Moro
R=1
25 1 Giulio Moro
PLLCLK_IN uses MCLK
26 1 Giulio Moro
CLKDIV_IN uses MCLK
27 1 Giulio Moro
PLLCLK is 12MHz
28 1 Giulio Moro
These values plugged in
29 1 Giulio Moro
  f_{S(ref)} = (PLLCLK_IN × K × R)/(2048 × P)
30 1 Giulio Moro
will give 44100
31 1 Giulio Moro
32 1 Giulio Moro
The media clock can be changed setting different values for J and D. As it is currently structured, the PRU loop does not allow you to get much faster than 48000kHz (J.D=K=8.1920) as you will start getting underruns.
33 1 Giulio Moro
34 1 Giulio Moro
As it turns out, on the BeagleRT cape the 12MHz clock is generated by the same master clock that drives the CPU, so these are going to be synced forever and ever (that is, do not expect any drift to occur between the media clock and the system clock).