This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] AM625:从 M4F 读取 GTC 计数器导致异常

Guru**** 2463330 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1477862/am625-reading-gtc-counter-from-m4f-caused-exception

器件型号:AM625

工具与软件:

以下简单代码导致异常:

tbl =(uint32_t)((uint8_t*) 0x00AA0000);

TBU = (uint32_t)((uint8_t*) 0x00AA0004);

如何使 AM625X 处理器的 M4F 内核能够访问 GTC 计数器寄存器?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Jim、您好!

    我还有一个主题、其中我写了有关 GTC 以及如何正确使用它的内容。 但仍然适用于 AM62x。 该线程的反应如下:

    GTC 应从它有的最后一个计数值继续计数(即使在 JTAG 复位时也是如此)。 这在 AM64x TRM 中提到、我已附加一个片段。 如果您详细了解一下、那会很有帮助。

    此外、我认为您需要在软复位时将 GTC 计数器值重置为零、因此我编写了一个小应用程序、在 JTAG 复位+运行应用程序后会执行相同的操作。

    在上面的屏幕截图中、我已经实现了4个步骤(在下面代码内的注释中)、我建议您使用随附的 C 文件中提到的流程来将计数器值重置为0。

    /*
     *  Copyright (C) 2021 Texas Instruments Incorporated
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include <stdio.h>
    #include <kernel/dpl/DebugP.h>
    #include <inttypes.h>
    #include "ti_drivers_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    #include <drivers/gtc.h>
    #include <drivers/soc.h>
    #include <drivers/gtc/v0/cslr_gtc.h>
    #include <kernel/dpl/ClockP.h>
    
    /*
     * This is an empty project provided for all cores present in the device.
     * User can use this project to start their application by adding more SysConfig modules.
     *
     * This application does driver and board init and just prints the pass string on the console.
     * In case of the main core, the print is redirected to the UART console.
     * For all other cores, CCS prints are used.
     */
    
    void GTC_disable(void);
    void GTC_clearCountRegisters(void);
    
    void hello_world_main(void *args)
    {
        int32_t retVal = SystemP_SUCCESS;
        uint64_t gtcCount1 = 0, gtcCount2 = 0;
        uint64_t clkRate = 0;
    
        /* Open drivers to open the UART driver for console */
        Drivers_open();
        Board_driversOpen();
    
        // This API is called to reset the 0th and 1st bit of the GTC0_GTC_CFG1_GTC_CFG1_CNTCR register
        GTC_disable();
        // Now clear the GTC0_GTC_CFG1_GTC_CFG1_CNTCV_LO and GTC0_GTC_CFG1_GTC_CFG1_CNTCV_HI registers
        GTC_clearCountRegisters();
    
        retVal = GTC_init();
        DebugP_assert(SystemP_SUCCESS == retVal);
    
        retVal = SOC_moduleGetClockFrequency(TISCI_DEV_GTC0, TISCI_DEV_GTC0_GTC_CLK, &clkRate);
        DebugP_assert(SystemP_SUCCESS == retVal);
    
        gtcCount1 = GTC_getCount64();
    
        ClockP_sleep(3);
    
        gtcCount2 = GTC_getCount64();
    
        DebugP_log("%lf is the time taken in seconds for testing GTC!!!\r\n",((Float64)((Float64)gtcCount2 - (Float64)gtcCount1) / (Float64)clkRate));
    
        Board_driversClose();
        Drivers_close();
    }
    
    
    void GTC_disable(void)
    {
        uint32_t baseAddr = (uint32_t) AddrTranslateP_getLocalAddr(CSL_GTC0_GTC_CFG1_BASE);
    
        HW_WR_REG32(baseAddr, 0);
    
        return;
    }
    void GTC_clearCountRegisters(void)
    {
        uint32_t baseAddr = (uint32_t) AddrTranslateP_getLocalAddr(CSL_GTC0_GTC_CFG1_BASE);
    
        HW_WR_REG32(baseAddr + CSL_GTC_CFG1_CNTCV_LO, 0); // Firstly, setting LO to 0
        HW_WR_REG32(baseAddr + CSL_GTC_CFG1_CNTCV_HI, 0); // Secondly, setting HI to 0
    
        return;
    }
    
    

    请告诉我这是否有助于您解决您的问题。

    此致、

    Vaibhav