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.

[参考译文] TDA4AEN-Q1:如何使用 timerP 创建 10m 基础 ISR?

Guru**** 2416110 points
Other Parts Discussed in Thread: SYSCONFIG

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

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1527972/tda4aen-q1-how-to-use-the-timerp-to-create-a-10m-base-isr

器件型号:TDA4AEN-Q1
主题:SysConfig 中讨论的其他器件

工具/软件:

您好:

   我处理的是 mcu_plus_sdk_j722s_10_01_00_22

  2. 附加我的 example.syscfg。 我在 example.syscfg 中添加以下行以用于计时器设置。

Timer1.$name =“CONFIG_TIMER0";“;
timer1.usecPerTick = 10000;
Timer1.timerCallback =“TimerISR";“;
Timer1.MCU_TIMER.$ASSIGN =“MCU_DMTIMER1";“;

   3.附件代码 ti_DPL_config.c 和 ti_dpl_config.h

   4.检查 TimerISR (args) 是否在内部调用。 请帮助我检查是否有任何问题。 我想在 mcu-R5fss0-0_freeRTOS 上进行构建。

e2e.ti.com/.../ti_5F00_dpl_5F00_config.he2e.ti.com/.../ti_5F00_dpl_5F00_config.c

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

    您好:

        再次附加 example.syscfg。

    /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --device "J722S_TDA4VEN_TDA4AEN_AM67" --package "AMW" --part "Default" --context "mcu-r5fss0-0" --product "MCU_PLUS_SDK@07.03.01"
     * @versions {"tool":"1.20.0+3587"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const ipc        = scripting.addModule("/drivers/ipc/ipc");
    const debug_log  = scripting.addModule("/kernel/dpl/debug_log");
    const mpu_armv7  = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
    const mpu_armv71 = mpu_armv7.addInstance();
    const mpu_armv72 = mpu_armv7.addInstance();
    const mpu_armv73 = mpu_armv7.addInstance();
    const mpu_armv74 = mpu_armv7.addInstance();
    const mpu_armv75 = mpu_armv7.addInstance();
    const mpu_armv76 = mpu_armv7.addInstance();
    const mpu_armv77 = mpu_armv7.addInstance();
    const mpu_armv78 = mpu_armv7.addInstance();
    const mpu_armv79 = mpu_armv7.addInstance();
    const timer      = scripting.addModule("/kernel/dpl/timer", {}, false);
    const timer1     = timer.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    ipc.vringAllocationPDK = false;
    
    debug_log.enableLogZoneWarning = false;
    debug_log.enableLogZoneError   = false;
    debug_log.enableCssLog         = false;
    debug_log.enableUartLog        = true;
    debug_log.uartLog.$name        = "CONFIG_UART0";
    debug_log.uartLog.intrEnable   = "DISABLE";
    
    mpu_armv71.baseAddr   = 0x0;
    mpu_armv71.size         = 31; /* 2 GB */
    mpu_armv71.attributes   = "Device";
    mpu_armv71.allowExecute = false;
    mpu_armv71.$name        = "CONFIG_MPU_REGISTER";
    
    mpu_armv72.baseAddr   = 0x0;
    mpu_armv72.size       = 15; /* 32 KB */
    mpu_armv72.$name      = "CONFIG_MPU_TCMA";
    mpu_armv72.allowExecute = true;
    mpu_armv72.attributes = "NonCached";
    
    mpu_armv73.baseAddr   = 0x41010000;
    mpu_armv73.size       = 15; /* 32 KB */
    mpu_armv73.$name      = "CONFIG_MPU_TCMB";
    mpu_armv73.allowExecute = true;
    mpu_armv73.attributes = "NonCached";
    
    mpu_armv74.baseAddr = 0x79100000;
    mpu_armv74.size     = 19; /* 512 KB */
    mpu_armv74.$name    = "CONFIG_MPU_MCU_MSRAM";
    mpu_armv74.allowExecute = true;
    
    mpu_armv75.baseAddr = 0x80000000;
    mpu_armv75.size     = 31; /* 2 GB */
    mpu_armv75.$name    = "CONFIG_MPU_DDR";
    mpu_armv75.allowExecute = true;
    
    mpu_armv76.baseAddr = 0x60000000;
    mpu_armv76.size     = 26; /* 64 MB */
    mpu_armv76.$name    = "CONFIG_MPU_FLASH";
    mpu_armv76.allowExecute = true;
    
    mpu_armv77.baseAddr = 0xA5000000;
    mpu_armv77.size     = 24; /* 32 MB */
    mpu_armv77.$name    = "RTOS_IPC_VRING";
    mpu_armv77.allowExecute = false;
    mpu_armv77.attributes   = "NonCached";
    
    mpu_armv78.$name        = "LINUX_VRING";
    mpu_armv78.baseAddr     = 0xA1000000;
    mpu_armv78.attributes   = "NonCached";
    mpu_armv78.size         = 20;
    mpu_armv78.allowExecute = false;
    
    mpu_armv79.attributes   = "NonCached";
    mpu_armv79.size         = 20;
    mpu_armv79.allowExecute = false;
    mpu_armv79.baseAddr     = 0xA1100000;
    mpu_armv79.$name        = "RESOURCE_TABLE_AND_TRACE";
    
    timer1.$name             = "CONFIG_TIMER0";
    timer1.usecPerTick       = 10000;
    timer1.timerCallback     = "TimerISR";
    timer1.MCU_TIMER.$assign = "MCU_DMTIMER1";
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    debug_log.uartLog.MCU_UART.$suggestSolution     = "MCU_USART0";
    debug_log.uartLog.MCU_UART.RXD.$suggestSolution = "MCU_UART0_RXD";
    debug_log.uartLog.MCU_UART.TXD.$suggestSolution = "MCU_UART0_TXD";
    

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

    您好、

    您能详细说明一下问题是什么吗? 您无法使用使用生成的代码使用 SysConfig 访问计时器 ISR 回调函数?

    谢谢、

    Neehar

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

    你好 Neehar:

       否、我已生成 example.syscfg。 如附件上方所示。 根据 example.syscfg、我已经构建了代码并生成了 R5F 映像。 但在 MCU R5F 上运行时非常有用。 我看不到 将调用 TimerISR()。 我将计时器调用 userPerTick 设置为 1000us。 为什么没有定期调用 TimerISR () 函数。  

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

    你好 Neehar:

       我希望创建时间周期函数的目标。 例如、我希望函数能够进行周期性的 10ms 调用。 现在、我想尝试使用 TimerP 模块来完成此操作。 或者、您能有任何在 J722S 平台上为我提供的示例代码吗?

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

    您好、

    我将进一步研究这一点、然后返回给您。

    谢谢、

    Neehar

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

    你好 Neehar:

        我已经在创建计时器 10m 周期性工作。 10M 定期触发我的 TimerISR () 并  将 SemaphoreP_POST 信号调用到另一个任务。  

        感谢您的帮助! 关闭案例!

    example.syscfg

    /**
     * Import the modules used in this configuration.
     */
    const ipc        = scripting.addModule("/drivers/ipc/ipc");
    const debug_log  = scripting.addModule("/kernel/dpl/debug_log");
    const mpu_armv7  = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
    const mpu_armv71 = mpu_armv7.addInstance();
    const mpu_armv72 = mpu_armv7.addInstance();
    const mpu_armv73 = mpu_armv7.addInstance();
    const mpu_armv74 = mpu_armv7.addInstance();
    const mpu_armv75 = mpu_armv7.addInstance();
    const mpu_armv76 = mpu_armv7.addInstance();
    const mpu_armv77 = mpu_armv7.addInstance();
    const mpu_armv78 = mpu_armv7.addInstance();
    const mpu_armv79 = mpu_armv7.addInstance();
    const timer      = scripting.addModule("/kernel/dpl/timer", {}, false);
    const timer1     = timer.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    ipc.vringAllocationPDK = false;
    
    debug_log.enableLogZoneWarning = false;
    debug_log.enableLogZoneError   = false;
    debug_log.enableCssLog         = false;
    debug_log.enableUartLog        = true;
    debug_log.uartLog.$name        = "CONFIG_UART0";
    debug_log.uartLog.intrEnable   = "DISABLE";
    
    mpu_armv71.baseAddr   = 0x0;
    mpu_armv71.size         = 31; /* 2 GB */
    mpu_armv71.attributes   = "Device";
    mpu_armv71.allowExecute = false;
    mpu_armv71.$name        = "CONFIG_MPU_REGISTER";
    
    mpu_armv72.baseAddr   = 0x0;
    mpu_armv72.size       = 15; /* 32 KB */
    mpu_armv72.$name      = "CONFIG_MPU_TCMA";
    mpu_armv72.allowExecute = true;
    mpu_armv72.attributes = "NonCached";
    
    mpu_armv73.baseAddr   = 0x41010000;
    mpu_armv73.size       = 15; /* 32 KB */
    mpu_armv73.$name      = "CONFIG_MPU_TCMB";
    mpu_armv73.allowExecute = true;
    mpu_armv73.attributes = "NonCached";
    
    mpu_armv74.baseAddr = 0x79100000;
    mpu_armv74.size     = 19; /* 512 KB */
    mpu_armv74.$name    = "CONFIG_MPU_MCU_MSRAM";
    mpu_armv74.allowExecute = true;
    
    mpu_armv75.baseAddr = 0x80000000;
    mpu_armv75.size     = 31; /* 2 GB */
    mpu_armv75.$name    = "CONFIG_MPU_DDR";
    mpu_armv75.allowExecute = true;
    
    mpu_armv76.baseAddr = 0x60000000;
    mpu_armv76.size     = 26; /* 64 MB */
    mpu_armv76.$name    = "CONFIG_MPU_FLASH";
    mpu_armv76.allowExecute = true;
    
    mpu_armv77.baseAddr = 0xA5000000;
    mpu_armv77.size     = 24; /* 32 MB */
    mpu_armv77.$name    = "RTOS_IPC_VRING";
    mpu_armv77.allowExecute = false;
    mpu_armv77.attributes   = "NonCached";
    
    mpu_armv78.$name        = "LINUX_VRING";
    mpu_armv78.baseAddr     = 0xA1000000;
    mpu_armv78.attributes   = "NonCached";
    mpu_armv78.size         = 20;
    mpu_armv78.allowExecute = false;
    
    mpu_armv79.attributes   = "NonCached";
    mpu_armv79.size         = 20;
    mpu_armv79.allowExecute = false;
    mpu_armv79.baseAddr     = 0xA1100000;
    mpu_armv79.$name        = "RESOURCE_TABLE_AND_TRACE";
    
    timer1.$name             = "CONFIG_TIMER0";
    timer1.usecPerTick       = 10000;
    timer1.timerCallback     = "TimerISR";
    timer1.MCU_TIMER.$assign = "MCU_DMTIMER1";
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    debug_log.uartLog.MCU_UART.$suggestSolution     = "MCU_USART0";
    debug_log.uartLog.MCU_UART.RXD.$suggestSolution = "MCU_UART0_RXD";
    debug_log.uartLog.MCU_UART.TXD.$suggestSolution = "MCU_UART0_TXD";
    

    计时器任务 ISR 代码:

    #include <stdio.h>
    #include <stdint.h>
    #include <string.h>
    
    #include <kernel/dpl/HwiP.h>
    #include <kernel/dpl/TimerP.h>
    #include <kernel/dpl/SemaphoreP.h>
    
    #include <cmd_common.h>
    #include <fih_timer_task_client.h>
    #include "ti_dpl_config.h"
    
    #define MSGSIZE  256U
    #define FBPAYLAD_SIZE 128
    #define LOG_TAG_TIMER "TimerClient"
    
    /* ========================================================================================================== */
    /* ============================================ Variable define ============================================= */
    /* ========================================================================================================== */
    static SemaphoreP_Object g_TaskSem;
    
    volatile uint64_t g_timerIsrCount  = 0U;
    uint32_t g_timer_task_ms = 0;
    
    /* ========================================================================== */
    /*                             FIH client task                                */
    /* ========================================================================== */
    static bool fih_timer_semaphore_init(void)
    {
    	/* Create semaphore to signal completion of load tasks */
    	if(SemaphoreP_constructBinary(&g_TaskSem, 0) != SystemP_SUCCESS) {
    		print_log(LOG_LV_ERR, "[%s %s]: SemaphoreP_constructBinary fail\n", LOG_TAG_TIMER, __func__);
    		return false;
    	}
    
    	return true;
    }
    
    static void timer_task_trigger(uint64_t base_timer_cnt)
    {
    	if ((base_timer_cnt % (g_timer_task_ms/TIMER_BASE_MS)) == 0) {
    		SemaphoreP_post(&g_TaskSem);
    	}
    }
    
    static bool fih_timer_create(void)
    {
    	/* pass timer ISR count value to ISR as argument */
    	HwiP_setArgs(&gTimerHwiObj[CONFIG_TIMER0], (void*)&g_timerIsrCount);
    
    	return true;
    }
    
    void TimerISR(void *arg)
    {
        volatile uint64_t *pTimerIsrCount = (uint64_t *)arg;
    	*pTimerIsrCount = *pTimerIsrCount + 1;
    
    	if(!g_timer_task_ms) {
    		return;
    	}
    
    	timer_task_trigger(*pTimerIsrCount);
    }
    
    bool fih_timer_init(void)
    {
    	/* init the semaphore for timer */
    	if(!fih_timer_semaphore_init()) {
    		print_log(LOG_LV_ERR, "[%s %s]: fail call fih_timer_semaphore_init\n", LOG_TAG_TIMER, __func__);
    		return false;
    	}
    
    	/* Create timer */
    	if(!fih_timer_create()) {
    		print_log(LOG_LV_ERR, "[%s %s]: fail call fih_timer_create\n", LOG_TAG_TIMER, __func__);
    		return false;
    	}
    
    	return true;
    }
    
    bool fih_timer_task_start(uint32_t base_timer_ms, uint32_t task_timer_ms)
    {
    	/* Valid the task_timer_ms value */
    	if((task_timer_ms % 10) != 0) {
    		print_log(LOG_LV_ERR, "[%s %s]: task_timer_ms doesn't 10\n", LOG_TAG_TIMER, __func__);
    		return false;
    	}
    	if(task_timer_ms < TIMER_BASE_MS) {
    		print_log(LOG_LV_ERR, "[%s %s]: task_timer_ms less then TIMER_BASE_MS\n", LOG_TAG_TIMER, __func__);
    		return false;
    	}
    
    	/* */
    	g_timer_task_ms = task_timer_ms;
    
    	/* Start timer process */
    	TimerP_start(gTimerBaseAddr[CONFIG_TIMER0]);
    
    	return true;
    }
    
    bool fih_timer_task_stop(void)
    {
    	/* Stop timer process */
    	TimerP_stop(gTimerBaseAddr[CONFIG_TIMER0]);
    
    	/* Clear timer count value */
    	g_timer_task_ms = 0;
    	g_timerIsrCount = 0;
    
    	/* Signal to timer task unlock last time SemaphoreP */
    	SemaphoreP_post(&g_TaskSem);
    
    	return true;
    }
    
    bool Timer_task_chk(void)
    {
    	/* Valid if the task timer setup */
    	if(g_timer_task_ms == 0) {
    		return false;
    	}
    
    	/* Block wait signal from timer isr processs */
    	if(SystemP_SUCCESS == SemaphoreP_pend(&g_TaskSem, SystemP_WAIT_FOREVER)) {
    		/* Got the signal from timer isr. */
    		return true;
    	}
    
    	return false;
    }