Generate 12.2880MHZ clock #338
-
Hi, I've been using a pcm1808 for i2s input. The devboard (TI PCM1808EVM) has a clock generator onboard. The current board i have to build into my device now does not have a clock generator. When i patch the 12.2880MHZ from the devboard to the sclk input on the current board it works! So I figure, i could let the pi generate the 12.2880MHZ clock. So far I have not been able to get it to work. I've been trying to generate a 12.2880MHZ clock like this: CKernel::CKernel (void)
: m_Screen (m_Options.GetWidth (), m_Options.GetHeight ()),
m_Timer (&m_Interrupt),
m_Logger (m_Options.GetLogLevel (), &m_Timer),
//m_Clock (GPIOClock0, GPIOClockSourcePLLD),
m_Clock (GPIOClock0, GPIOClockSourcePLLC),
...
if(!m_Clock.StartRate(12288000))
{
m_Logger.Write (FromKernel, LogError, "Could not set clock rate");
} But i always get back a false, could not set clock rate. Is this rate impossible for the pi to generate? Unfortunately I do not have a logic analyzer to see what's going on. I assume I need to use GPIO4 with this GPIOClock0? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Figured it out! in case anyone is looking for a similar solution, here's my not so clean but working code: CKernel::CKernel (void)
: m_Screen (m_Options.GetWidth (), m_Options.GetHeight ()),
m_Timer (&m_Interrupt),
m_Logger (m_Options.GetLogLevel (), &m_Timer),
m_Clock (GPIOClock2, GPIOClockSourceOscillator), // I used GPIOClock2 because it was the only pin that was not used on my board, and Clock Source Oscillator was the only source that worked
...
m_SCLKPin.AssignPin (6);//31);
m_SCLKPin.SetMode (GPIOModeAlternateFunction0);
m_Logger.Write (FromKernel, LogNotice, "Start SCLK");
unsigned nSampleRate = SAMPLE_RATE;
unsigned nChanLen = 32;
unsigned nChans = 2;
unsigned nClockFreq =
CMachineInfo::Get ()->GetGPIOClockSourceRate (GPIOClockSourceOscillator);
assert (nClockFreq > 0);
assert (8000 <= nSampleRate && nSampleRate <= 192000);
assert (nClockFreq % (nChanLen*nChans) == 0);
double fDiv = nClockFreq / 512.0 / nSampleRate; // 512 = frame size, on my pcm1808 board this is set using the md0 pin; set it high
unsigned nDivI = fDiv;
unsigned nDivF = (fDiv - nDivI) * 4096.0 + 0.5;
assert (nDivF <= 4096);
if (nDivF > 4095)
{
nDivI++;
nDivF = 0;
}
m_Clock.Start (nDivI, nDivF, nDivF > 0 ? 1 : 0); |
Beta Was this translation helpful? Give feedback.
Figured it out!
in case anyone is looking for a similar solution, here's my not so clean but working code: