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.

[参考译文] AM263x-AM263X:MCU-PLUS-SDK TI LP

Guru**** 2557650 points


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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1536903/mcu-plus-sdk-am263x-am263x-ti-lp



工具/软件:

尊敬的 TI 团队  

我正在尝试运行 中断模式下的 ADC0 通道 0 。 当 ADC 中断正常工作时、 未调用回调函数 亮起。

您能查看下面的代码片段、告诉我可能缺少哪些内容吗?

此外、我已经查看了 MCU+ SDK 10.02 示例。 adc_soc_continuous_dma我注意到示例中定义了两个回调函数、但它们似乎都不是由任何中断触发的。

期待您就此问题提供指导。

静态 void App_adcISR (void *args);
static void App_dmach0isr (Edma_Intr 处理程序、void *args);  

这些是 SDK 示例代码的函数  

这是我的代码   

注意 — 代码正常工作,根据输入电压,ADC 转换正确。  

#include
#include “ti_drivers_config.h"</s>“
#include “ti_board_config.h"</s>“
#include
#include
#include
#include

void hello_world_main (void * args);
void Uart_Inti ();
HwiP_Params ADC_params;
HwiP_Object my_adc;

#define CSLR_R5FSS0_CORE0_INTR_ADC0_INTR_0 (150u)
long unsigned int 计数= 0;

void adc_isr (void *arg)//此函数是回调函数、ADC 需要检查是否正在调用

count++;
DebugP_log(“调用 ADC 回调\r\n“);
}
空 adcOpen ()

HwiP_Params_init (&ADC_params);
adc_params.intNum = CSLR_R5FSS0_CORE0_INTR_ADC0_INTR_0;
adc_params.callback =&ADC_ISR;
adc_params.priority = 10;

ADC_setupSOC (CONFIG_ADC0_BASE_ADDR、0、ADC_TRIGGER_SW_ONLY、ADC_CH_ADCIN0、16);
ADC_enableConverter (CONFIG_ADC0_BASE_ADDR);
/* ADC 上电延迟。 */
ClockP_USleep (500);
ADC_enableInterrupt (CONFIG_ADC0_BASE_ADDR、0);
// HwiP_Params_init (&ADC_params);
HwiP_construct (&my_adc、&adc_params);
}

内部 main (void)


system_init();
BOARD_INIT ();
hello_world_main (NULL);
DebugP_LOG(“Start Initialize ADC0 \r\n“);
adcOpen();

while (1)

ADC_clearInterruptStatus (CONFIG_ADC0_BASE_ADDR、ADC_INT_number1);
ADC_forceSOC (CONFIG_ADC0_BASE_ADDR、ADC_SOC_NUMBER0);
while (ADC_getInterruptStatus (CONFIG_ADC0_BASE_ADDR、ADC_INT_number1)= false)

}
DebugP_log(“CH0:%d\r\n“、ADC_readResult (CONFIG_ADC0_RESULT_BASE_ADDR、ADC_SOC_NUMBER0));
DebugP_log(“%d:“、count);
GPIO_pinWriteHigh (LED_RED_BASE_ADDR、LED_RED_PIN);
ClockP_SLEEP (1);
GPIO_pinWriteLow (LED_RED_BASE_ADDR、LED_RED_PIN);
ClockP_SLEEP (1);
//count=0;
}
BOARD_DEINIT();
system_deinit();
返回 0;
}

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

    您好、Vipul

    您还可以与我共享您的 syscfg 文件吗?

    此致、
    阿克什特

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

    您好、Akshit  

    我直接上传.syscfg 文件时遇到了一些问题、因此我将其格式更改为.jpg、因此请将其转换回.syscfg 格式、请告诉我您是否能够打开此文件。  

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

    您好、Vipul

    您可以在.syscfg 文件中发送代码、也可以在记事本或任何其他文本编辑器中打开该文件并将 example.syscfg 的内容粘贴到此处、我无法通过.jpg 访问它

    谢谢、
    阿克什特

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

    您好、Akshit  

    请收集.txte2e.ti.com/.../3566.example.syscfg.txt

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

    您好、Vipul

    发生此问题的原因是您尚未配置 INT_XBAR 以将 ADC 中断信号路由到 VIM。

    这样、您还需要将 intnum 注册为 INT_XBAR 的 intnum:

    //初始化 HwiP 参数
    HwiP_Params_init (&ADC_params);
    adc_params.intNum = CSLR_R5FSS0_CORE0_CONTROLSS_INTRXBAR0_OUT_0;//使用交叉开关输出
    adc_params.callback =&ADC_ISR;
    adc_params.priority = 10

    附加下面的完整代码文件:

    /*
     *  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 "ti_drivers_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.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.
     */
    
     // Hardware interrupt object and parameters
    static HwiP_Object gAdcHwiObject;
    static HwiP_Params adc_params;
    
    long unsigned int count = 0;
    
    void adc_isr(void *arg) 
    {
        count++;
        DebugP_log("ADC callback invoked! Count: %lu\r\n", count);
        
        // Clear the interrupt flag that triggered this ISR
        ADC_clearInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1);
    }
    
    void empty_main(void *args)
    {
        int32_t status;
        uint32_t loopCnt = 10;
    
        /* Open drivers to open the UART driver for console */
        Drivers_open();
        Board_driversOpen();
    
        // Initialize HwiP parameters
        HwiP_Params_init(&adc_params);
        adc_params.intNum = CSLR_R5FSS0_CORE0_CONTROLSS_INTRXBAR0_OUT_0;  // Use crossbar output
        adc_params.callback = &adc_isr;
        adc_params.priority = 10;
    
        // Construct the hardware interrupt
        status = HwiP_construct(&gAdcHwiObject, &adc_params);
        if(status != SystemP_SUCCESS)
        {
            DebugP_log("Failed to construct HwiP object\r\n");
            return;
        }
    
        // Clear any pending interrupt status
        ADC_clearInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1);
    
        DebugP_log("ADC interrupt configuration completed\r\n");
    
        while(loopCnt--)
        {
            // Force SOC0 to start conversion - this should trigger the interrupt
            ADC_forceSOC(CONFIG_ADC0_BASE_ADDR, ADC_SOC_NUMBER0);
            
            // Wait for conversion to complete by checking interrupt status
            while(ADC_getInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1) == false)
            {
                // Wait for interrupt
            }
            
            // Read the conversion result
            uint16_t adcResult = ADC_readResult(CONFIG_ADC0_RESULT_BASE_ADDR, ADC_SOC_NUMBER0);
            DebugP_log("CH0 : %d, Callback count: %lu\r\n", adcResult, count);
        }
    
    #if defined(AMP_FREERTOS_A53)
        DebugP_log("All tests have passed on a53_core%d!!\r\n", Armv8_getCoreId());
    #else
        DebugP_log("All tests have passed!!\r\n");
    #endif 
        Board_driversClose();
        Drivers_close();
    }
    

    通过这一点、我能够确认回调是否正常工作、并且还可以中断它:

    此致、
    阿克什特

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

    您好、Akshit  

    谢谢你的快速支持,现在它的工作..