UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
2,530 Views
Registered: ‎01-24-2014

Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

I am using the clock wizard v5.3 for dynamic clock reconfiguration. By searching the similar topics, I didn't get any significant help.

 

My clock wizard configuration is as follow:

clk_wiz_config.png

 

By following the chapter in document pg065 about "Dynamic Reconfiguration through AXI4-Lite", I have developed the code to reconfigure the clock. But after writing the configuration registers, I never read clock locked bit as '1' at address "xclk_config->BaseAddr+0x04"using Xil_In32.

 

By the way, I am using the linux based c code where the base address has been mapped into /dev/mem.

 

Does anyone have any successful experience ?

 

Thanks a lot.

0 Kudos
1 Solution

Accepted Solutions
Adventurer
Adventurer
3,630 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for the suggestions.

 

I have made another project with much simpler design with Xilinx IP ONLY. It is for testing the dynamic reconfiguration of clock wizard only. This time everything works.

 

So I guess my custom peripheral still has some problem that the multiple clocks just cannot lock.

 

Anyway, thanks for all the help and suggestions.

 

I have attached the exported block design and corresponding code here in case someone else is trying to study it. This design is using Vivado 2016.4 on ZedZynq zc702. Hope it will helps.

 

All the best !

0 Kudos
16 Replies
Moderator
Moderator
2,448 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

Did you write at address 0x25C to update the register value?

 

Did you follow the Example for Dynamic Reconfiguration through AXI4-Lite from the pg065?

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Adventurer
Adventurer
2,437 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for the reply. 

 

Actually, I have not got that far yet. I am following an example code for clock wizard and try to access clock wizard under linux OS. Currently, what I am doing is to check if the clock is locked first. Once it is locked, I will start set the mult and div and set load ans sen as the example did. But the thing is, I have not get successful access to the clock wizard from userspace yet. 

 

Here is my code: 

 

XClk_Wiz_Config *xclk_config0;
XClk_Wiz *xclk_inst0;

xclk_config0 = (XClk_Wiz_Config *) malloc(sizeof(XClk_Wiz));
xclk_inst0 = (XClk_Wiz *) malloc(sizeof(XClk_Wiz));

u32 Status = XST_SUCCESS;
void *mapped_base;

int fdmem = open("/dev/mem", O_RDWR | O_SYNC);

printf("Looking up %d^th clk_wiz\n", XPAR_CLK_WIZ_0_DEVICE_ID);
xclk_config0 = XClk_Wiz_LookupConfig(XPAR_CLK_WIZ_0_DEVICE_ID);
if (!xclk_config0) {
return XST_FAILURE;
}
printf("re-mapping %d^th clk_wiz's base address 0x%x to ", XPAR_CLK_WIZ_0_DEVICE_ID, xclk_config0->BaseAddr);
mapped_base = mmap(0, MAP_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fdmem, xclk_config0->BaseAddr & ~MAP_MASK);
printf("0x%x ", mapped_base);
xclk_config0->BaseAddr = mapped_base + (xclk_config0->BaseAddr & MAP_MASK);
printf("0x%x. \n", xclk_config0->BaseAddr);

printf("Initializing %d^th clk_wiz's configuration\n", XPAR_CLK_WIZ_0_DEVICE_ID);
Status = XClk_Wiz_CfgInitialize(xclk_inst0, xclk_config0, xclk_config0->BaseAddr);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

printf("base address of %d^th clk_wiz is: 0x%x\n", XPAR_CLK_WIZ_0_DEVICE_ID, xclk_config0->BaseAddr);
if(xclk_config0->EnableClkMon == 0) {
printf("Interrupt test only applicable for clock monitor\r\n");
return XST_SUCCESS;
}

u32 Count = 0;
u32 Error = 0;
while(!(*(u32 *)(xclk_config0->BaseAddr + 0x04) & CLK_LOCK)) {
if(Count == 10000) {
Error++;
break;
}
Count++;
}
if(Error) {
printf("\n ERROR: Clock is not locked for default frequency : 0x%x\n\r", *(u32 *)(xclk_config0->BaseAddr + 0x04) & CLK_LOCK);
exit(0);
}

 

Once I run the code, the linux OS will crashed. It seems it does not allow to access the clock wizard from the mapped userspace memory.:

 

root@linaro-ubuntu-desktop:~# ./mmcm_tuning.elf
Looking up 0^th clk_wiz
re-mapping 0^th clk_wiz's base address 0x43c20000 to 0xb6f8c000.
Initializing 0^th clk_wiz's configuration
base address of 0^th clk_wiz is: 0xb6f8c000

 

 

0 Kudos
Moderator
Moderator
2,432 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

Could you try first with a baremetal application and switch later to the linux OS? It will be a bit easier to debug.

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Adventurer
Adventurer
2,419 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks a lot for the suggestion.

 

I have changed the code for the bare-metal application. It still does not work. Here is the code:


    init_platform();

    xil_printf("Hello World\n\r");

    XClk_Wiz_Config *xclk_config0;
    XClk_Wiz *xclk_inst0;

    xclk_config0 = (XClk_Wiz_Config *) malloc(sizeof(XClk_Wiz));
    xclk_inst0 = (XClk_Wiz *) malloc(sizeof(XClk_Wiz));

    u32 Status = XST_SUCCESS;

    xil_printf("Looking up %d^th clk_wiz\n", XPAR_CLK_WIZ_0_DEVICE_ID);
    xclk_config0 = XClk_Wiz_LookupConfig(XPAR_CLK_WIZ_0_DEVICE_ID);
    if (!xclk_config0) {
        return XST_FAILURE;
    }
    xil_printf("0x%x. \n", xclk_config0->BaseAddr);

    xil_printf("Initializing %d^th clk_wiz's configuration\n", XPAR_CLK_WIZ_0_DEVICE_ID);
    Status = XClk_Wiz_CfgInitialize(xclk_inst0, xclk_config0, xclk_config0->BaseAddr);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    xil_printf("base address of %d^th clk_wiz is: 0x%x\n", XPAR_CLK_WIZ_0_DEVICE_ID, xclk_config0->BaseAddr);
    if(xclk_config0->EnableClkMon == 0) {
        xil_printf("Interrupt test only applicable for clock monitor\r\n");
        return XST_SUCCESS;
    }

    print("checking clock lock ... \n");
    u32 Count = 0;
    u32 Error = 0;
    while(!(*(u32 *)(xclk_config0->BaseAddr + 0x04) & CLK_LOCK)) {
        if(Count == 10000) {
            Error++;
            break;
        }
        Count++;
    }
    if(Error) {
        xil_printf("\n ERROR: Clock is not locked for default frequency : 0x%x\n\r", *(u32 *)(xclk_config0->BaseAddr + 0x04) & CLK_LOCK);
        exit(0);
    }
    print("clock is locked \n");

    cleanup_platform();
    return 0;

 

The code above will make the arm processor halt just like the previous linux application:

Hello World
Looking up 0^th clk_wiz
0x43C20000.
Initializing 0^th clk_wiz's configuration
base address of 0^th clk_wiz is: 0x43C20000
checking clock lock ...

 

So I guess it is not the software problem, since the address and offset are both come from the xilinx document example. I also try to connect a LED to the locked output, but the LED does not light on. Does that mean my design failed to have locked clock ? What else did I miss here in the design ?

 

Here is my screenshot of the clock wizard block diagram:

clk_wiz.jpg

clk_wiz_set01.jpgclk_wiz_set02.jpgclk_wiz_set03.jpgclk_wiz_set04.jpg

0 Kudos
Moderator
Moderator
2,414 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

Could you try to declare variables instead of pointers for (so do not do malloc):

XClk_Wiz_Config *xclk_config0;
XClk_Wiz *xclk_inst0;

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Adventurer
Adventurer
2,410 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for pointing out it.

 

I have commend those two lines of malloc. But still the same.

 

The reason I am using pointer of XClk_Wiz_Config and XClk_Wiz is that the standard clock wizard driver function XClk_Wiz_LookupConfig() returns the pointer of XClk_Wiz_Config.

 

I guess it should be ok to use pointer here since the driver uses the pointer based function.

0 Kudos
Moderator
Moderator
2,401 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

I have commend those two lines of malloc. But still the same.

->Also try not to use pointers but variables. Change to

XClk_Wiz_Config xclk_config0;
XClk_Wiz xclk_inst0;

And then give the addresses to the functions.

 

I have seen some weird behavior when using pointers for the instances.

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Adventurer
Adventurer
2,397 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for the suggestion.

 

I have done the modification by changing the instance from pointer to variable. But the program still stop the processor when trying to check if the clock is locked.

 

Code:


    init_platform();

    xil_printf("Hello World\n\r");

    XClk_Wiz_Config *xclk_config0;
    XClk_Wiz xclk_inst0;

    u32 Status = XST_SUCCESS;

    xil_printf("Looking up %d^th clk_wiz\n", XPAR_CLK_WIZ_0_DEVICE_ID);
    xclk_config0 = XClk_Wiz_LookupConfig(XPAR_CLK_WIZ_0_DEVICE_ID);
    if (!xclk_config0) {
        return XST_FAILURE;
    }
    xil_printf("0x%x. \n", xclk_config0->BaseAddr);

    xil_printf("Initializing %d^th clk_wiz's configuration\n", XPAR_CLK_WIZ_0_DEVICE_ID);
    Status = XClk_Wiz_CfgInitialize(&xclk_inst0, xclk_config0, xclk_config0->BaseAddr);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    xil_printf("base address of %d^th clk_wiz is: 0x%x\n", XPAR_CLK_WIZ_0_DEVICE_ID, xclk_config0->BaseAddr);
    if(xclk_config0->EnableClkMon == 0) {
        xil_printf("Interrupt test only applicable for clock monitor\r\n");
        return XST_SUCCESS;
    }

    print("checking clock lock ... \n");
    u32 Count = 0;
    u32 Error = 0;
    while(!(*(u32 *)(xclk_config0->BaseAddr + 0x04) & CLK_LOCK)) {
        if(Count == 10000) {
            Error++;
            break;
        }
        Count++;
    }
    if(Error) {
        xil_printf("\n ERROR: Clock is not locked for default frequency : 0x%x\n\r", *(u32 *)(xclk_config0->BaseAddr + 0x04) & CLK_LOCK);
        exit(0);
    }
    print("clock is locked \n");

    cleanup_platform();
    return 0;

 

 

Output:

Hello World
Looking up 0^th clk_wiz
0x43C20000.
Initializing 0^th clk_wiz's configuration
base address of 0^th clk_wiz is: 0x43C20000
checking clock lock ...

 

 

Thanks.

0 Kudos
Moderator
Moderator
2,385 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

You are still using a pointer for:

XClk_Wiz_Config *xclk_config0;

 

Please also try with a variable:

XClk_Wiz_Config xclk_config0;


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Highlighted
Adventurer
Adventurer
1,962 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for the suggestion.

 

The reason I am using pointer is because the official driver is using pointer as the return value.

 

This function is defined in xclk_wiz_sinit.c in the board support package. Please see the code of official driver bellow:

 

/******************************************************************************
*
* Copyright (C) 2016 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file xclk_wiz_sinit.c
* @addtogroup clk_wiz_v1_0
* @{
*
* Look up the hardware settings using device ID. The hardware setting is inside
* the configuration table in xclk_wiz_g.c, generated automatically by XPS or
* manually by the user.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date     Changes
* ----- ---- -------- -------------------------------------------------------
* 1.0 ram 02/12/16 Initial version for Clock Wizard
* </pre>
*
******************************************************************************/

/***************************** Include Files *********************************/

#include "xparameters.h"
#include "xclk_wiz.h"

/*****************************************************************************/
/**
 * Look up the hardware configuration for a device instance
 *
 * @param    DeviceId is the unique device ID of the device to lookup for
 *
 * @return    The reference to the configuration record in the configuration
 *         table (in xclk_wiz_g.c) corresponding to the Device ID or if
 *        not found, a NULL pointer is returned.
 *
 * @note    None
 *
 *****************************************************************************/
XClk_Wiz_Config *XClk_Wiz_LookupConfig(u32 DeviceId)
{
    extern XClk_Wiz_Config XClk_Wiz_ConfigTable[];
    XClk_Wiz_Config *CfgPtr = NULL;
    u32 Index;

    for (Index = 0; Index < XPAR_XCLK_WIZ_NUM_INSTANCES; Index++) {
        if (XClk_Wiz_ConfigTable[Index].DeviceId == DeviceId) {
            CfgPtr = &XClk_Wiz_ConfigTable[Index];
            break;
        }
    }

    return CfgPtr;
}
/** @} */

0 Kudos
Moderator
Moderator
1,956 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

Ok...

 

Could you tryreadind the lock signal as per the following

while(Xil_In32(xclk_config0->BaseAddr+ 0x04)& CLK_LOCK)

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Adventurer
Adventurer
1,951 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for the suggestion.

 

As you can see, the code is changed:


    u32 lock_read = Xil_In32(xclk_config0->BaseAddr + 0x04);
    while(!( lock_read & CLK_LOCK)) {
        if(Count == 10000) {
            Error++;
            break;
        }
        Count++;
    }

 

This does not change anything. As you can see, there no sign of clock locked.

 

Hello World
Looking up 0^th clk_wiz
0x43C20000.
Initializing 0^th clk_wiz's configuration
base address of 0^th clk_wiz is: 0x43C20000
checking clock lock ...

 

Is there any reference design using clock wizard ?

0 Kudos
Moderator
Moderator
1,949 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

HI @wincle,

 

I don't know any example with only the clocking wizard. But some xapp are using it. As the xapp1285


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Moderator
Moderator
1,943 Views
Registered: ‎11-09-2015

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,

 

I have one more suggestion:

Could you try to add an ILA on the AXI interface of your clock wizard? This way we can know if your processor is actually doing the reading.

 

And just a check:

Did you updated the hdf file in SDK after modifying the design in vivado? You might want to restart a SDK project to be sure.

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Adventurer
Adventurer
3,631 Views
Registered: ‎01-24-2014

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Thanks for the suggestions.

 

I have made another project with much simpler design with Xilinx IP ONLY. It is for testing the dynamic reconfiguration of clock wizard only. This time everything works.

 

So I guess my custom peripheral still has some problem that the multiple clocks just cannot lock.

 

Anyway, thanks for all the help and suggestions.

 

I have attached the exported block design and corresponding code here in case someone else is trying to study it. This design is using Vivado 2016.4 on ZedZynq zc702. Hope it will helps.

 

All the best !

0 Kudos
Observer cosminpanzaru1
Observer
1,259 Views
Registered: ‎05-24-2018

Re: Clock is not locked when using clock wizard for dynamic clock reconfiguration

Jump to solution

Hi @wincle,,

 

I want to understand you helloworld.c. By the way thank you for attaching those file.

Why did you use mmap function ?

 

 

Kind regards,

Cosmin

0 Kudos