Summary for baremetal LMK&LMX program.
- LMK should be initialize manually by GPIOs before writing registers.
XGpioPs Gpio;
XGpioPs_Config *GpioConfigPtr;
GpioConfigPtr = XGpioPs_LookupConfig(XPAR_GPIO_BASEADDR);
XGpioPs_CfgInitialize(&Gpio, GpioConfigPtr,
GpioConfigPtr->BaseAddr);
XGpioPs_SetDirectionPin(&Gpio, MIO_LMK_RST, 1);
XGpioPs_SetOutputEnablePin(&Gpio, MIO_LMK_RST, 1);
XGpioPs_WritePin(&Gpio, MIO_LMK_RST, 1);//lmk_reset.write(1)
XGpioPs_WritePin(&Gpio, MIO_LMK_RST, 0);//lmk_reset.write(0)
XGpioPs_SetDirectionPin(&Gpio, MIO_LMK_CLK_IN_SEL0, 1);
XGpioPs_SetOutputEnablePin(&Gpio, MIO_LMK_CLK_IN_SEL0, 1);
XGpioPs_WritePin(&Gpio, MIO_LMK_CLK_IN_SEL0, 0);//lmk_clk_sel0.write(0)
XGpioPs_SetDirectionPin(&Gpio, MIO_LMK_CLK_IN_SEL1, 1);
XGpioPs_SetOutputEnablePin(&Gpio, MIO_LMK_CLK_IN_SEL1, 1);
XGpioPs_WritePin(&Gpio, MIO_LMK_CLK_IN_SEL1, 0);//lmk_clk_sel1.write(0)
- LMXs should be reset first, by writing reset values to register.
u32 reset = 0x020000;//write reset
TempBuffer[2] = reset & 0xFF;
TempBuffer[1] = (reset>>8) & 0xFF;
TempBuffer[0] = (reset>>16) & 0xFF;
XSpiPs_SetSlaveSelect(SpiInstancePtr, slave_select);
Status = XSpiPs_PolledTransfer(SpiInstancePtr, TempBuffer,
NULL, 3);
reset = 0x000000;//remove reset
TempBuffer[2] = reset & 0xFF;
TempBuffer[1] = (reset>>8) & 0xFF;
TempBuffer[0] = (reset>>16) & 0xFF;
Status = XSpiPs_PolledTransfer(SpiInstancePtr, TempBuffer,
NULL, 3);
- Register values should be configured very carefully through TICS pro.
I used PYNQ official register values, but it won’t work for PLL1 of LMK, it will not lock. Howerer, after I changed some settings for PLL1, it locked successfully.
Download register values from here, then load it in TICS, and change value of ‘Phase Dector Fre’, ‘PLL1 R Dividers’ and ‘N divider’ for PLL1 as shown in the figure. After that, export and use the HEX values.
If you want to build a baremetal project, code and register values for clk congifure is in the attached C code as a reference.
LMK_LMX.c (11.0 KB)
