AM5728的DSP核,GPIO中断响应滞后的问题(代码基于SYSBIO) - AM57x - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3100|回复: 1

[已解决] AM5728的DSP核,GPIO中断响应滞后的问题(代码基于SYSBIO)

[复制链接]

6

主题

12

帖子

1070

积分

金牌会员

Rank: 6Rank: 6

积分
1070
发表于 2019-3-27 14:55:23 | 显示全部楼层 |阅读模式
大家好!
     我用AM5728的DSP核,GPIO6_4作为GPIO中断脚,中断能响应,但中断不及时,会滞后,以下是我的测试代码,请帮忙看看是不是配置有问题,谢谢。
/* xdctools header files */
#include <xdc/std.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/System.h>

/* package header files */
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MultiProc.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/hal/Hwi.h>
#include <ti/sysbios/knl/Clock.h>


/* local header files */
#include "Server.h"
#include "rsc_table_dsp1.h"

#include <ti/csl/soc/am572x/src/csl_device_xbar.h>
#include <ti/csl/soc/am572x/src/cslr_soc_aliases.h>
#include <ti/csl/soc/am572x/src/cslr_soc_dsp_baseaddress.h>
#include <ti/csl/src/ip/gpio/V1/gpio_v2.h>
#include <ti/osal/RegisterIntr.h>

#include <ti/sysbios/family/shared/vayu/IntXbar.h>



#define RAW_DEBUG_ENABLE


#ifdef RAW_DEBUG_ENABLE
#define rawDebug System_printf
#else
#define rawDebug(...)
#endif

uint32_t intrRegister;





//gpio6_4 作为中断输入
uint32_t gpio6_base_address = 0x4805D000;        //GPIO6
#define  GPIO_PIN_INT   4
uint32_t *pad_gpio6_4 = (uint32_t*)0x4A0036E8;   //GPIO6_4

uint32_t *pad_gpio6_6 = (uint32_t*)0x4A0036F0;   //GPIO6_6
#define  GPIO6_PIN6_OUT   6




//gpio3_1 作为IO输出
uint32_t gpio3_base_address = 0x48057000U;       //GPIO3
#define  GPIO3_PIN1_OUT   1
uint32_t *pad_gpio3_1 = (uint32_t*)0x4A0034E8;   //gpio3_1






volatile uint32_t flag=1;

static void myIsr(void)
{       
    //uint32_t flag=0;
        volatile uint32_t dl=5;
        GPIOPinIntClear(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);
       
        GPIOPinWrite(gpio3_base_address, GPIO_PIN_OUT, 0);
        while(dl--);
        GPIOPinWrite(gpio3_base_address, GPIO_PIN_OUT, 1);       


}


Void clk0Fxn(UArg arg0)
{

        #if 1
        if (flag==0)
        {
                flag = 1;
        }
        else
        {
                flag = 0;
        }

        rawDebug("clk0Fxn---->>>>  flag=%x \r\n",flag);
       
        //volatile uint32_t dl=5;
        //GPIOPinWrite(gpio3_base_address, GPIO3_PIN1_OUT, flag);
        GPIOPinWrite(gpio6_base_address, GPIO6_PIN6_OUT, flag);
        //while(dl--);
        //GPIOPinWrite(gpio3_base_address, GPIO_PIN_OUT, flag);
       
        #endif
}

void gpio3_1_pad_init(void)
{
    *pad_gpio3_1 &= ~1;
        *pad_gpio3_1 |= (0x3<<17) | 0xe;
}


void gpio6_4_pad_init(void)
{
    *pad_gpio6_4 &= ~1;
        *pad_gpio6_4 |= (0x3<<17) | 0xe;
}

void gpio6_6_pad_init(void)
{
    *pad_gpio6_6 &= ~1;
        *pad_gpio6_6 |= (0x3<<17) | 0xe;
}


void interrupt_init(void)
{
    int32_t retVal = 0;

        /* Initialize with defaults */
       
        CSL_XbarIrq intrSource;
        /* XBar configuration */
        intrSource = CSL_XBAR_GPIO6_IRQ_1;

        IntXbar_disconnectIRQ(62);           
        IntXbar_connectIRQ(62, intrSource);
        OsalRegisterIntrParams_t interruptRegParams;
        HwiP_Handle hwiPHandlePtr;
    Osal_RegisterInterrupt_initParams(&interruptRegParams);

    /* Populate the interrupt parameters */
    interruptRegParams.corepacConfig.arg = NULL;
    interruptRegParams.corepacConfig.name = NULL;
    interruptRegParams.corepacConfig.isrRoutine = myIsr;
    interruptRegParams.corepacConfig.priority = 0x1U;

    interruptRegParams.corepacConfig.intVecNum = 16; /* Corresponds to IPU1_IRQ_30 */
    interruptRegParams.corepacConfig.corepacEventNum = 62;


    /* Register interrupts */
    if( !intrRegister )
    {
         retVal = Osal_RegisterInterrupt(&interruptRegParams, &hwiPHandlePtr);

    }
    else
    {
        intrRegister = (uint32_t) TRUE;
    }

        gpio6_4_pad_init();

        /*Reset GPIO*/
    GPIOModuleReset(gpio6_base_address);

    /*Enable GPIO*/
    GPIOModuleEnable(gpio6_base_address);

       
        GPIOIntTypeSet(gpio6_base_address, GPIO_PIN_INT, 0x20); //设置下降沿
        GPIODirModeSet(gpio6_base_address, GPIO_PIN_INT, 1);    //设置为输入模式
        GPIOPinIntDisable(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);
    GPIOPinIntClear(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);

    /*Enable interrupt*/
    GPIOPinIntEnable(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);
}


void hwi_init(void)
{
    int32_t retVal = 0;

        /* Initialize with defaults */
       
        CSL_XbarIrq intrSource;
        /* XBar configuration */
        intrSource = CSL_XBAR_GPIO6_IRQ_1;

        IntXbar_disconnectIRQ(60);           
        IntXbar_connectIRQ(60, intrSource);

        Hwi_Handle hwi0;
    Hwi_Params hwiParams0;
        Error_Block eb;

        Error_init(&eb);
        Hwi_Params_init(&hwiParams0);
        hwiParams0.eventId = 60;
        hwiParams0.arg = 0;
        hwiParams0.maskSetting = Hwi_MaskingOption_SELF;
        hwiParams0.enableInt = TRUE;
        hwi0 = Hwi_create(4, myIsr, &hwiParams0, &eb);
        if(hwi0 == NULL)
        {
            rawDebug("Hwi_create ok \r\n");  
        }


        gpio6_4_pad_init();

        /*Reset GPIO*/
    GPIOModuleReset(gpio6_base_address);

    /*Enable GPIO*/
    GPIOModuleEnable(gpio6_base_address);

       
        GPIOIntTypeSet(gpio6_base_address, GPIO_PIN_INT, 0x20); //设置下降沿
        GPIODirModeSet(gpio6_base_address, GPIO_PIN_INT, 1);    //设置为输入模式
        GPIOPinIntDisable(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);
    GPIOPinIntClear(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);

    /*Enable interrupt*/
    GPIOPinIntEnable(gpio6_base_address, GPIO_INT_LINE_1, GPIO_PIN_INT);
}


void outgpio_init(void)
{
    gpio3_1_pad_init();
        GPIOModuleReset(gpio3_base_address);
    GPIOModuleEnable(gpio3_base_address);        //
    GPIODirModeSet(gpio3_base_address, GPIO3_PIN1_OUT, 0);    //
}

void gpio6_6_outout_init(void)
{
    gpio6_6_pad_init();
        //GPIOModuleReset(gpio6_base_address);
    //GPIOModuleEnable(gpio6_base_address);        //
    GPIODirModeSet(gpio6_base_address, GPIO6_PIN6_OUT, 0);    //
}
Int main(Int argc, Char* argv[])
{
    rawDebug("hwi_init \r\n");
        hwi_init();
        rawDebug("outgpio_init \r\n");
    outgpio_init();
        gpio6_6_outout_init();

#if 1       
        Clock_Params clkParams;
    Clock_Params_init(&clkParams);
    clkParams.period = 500;
    clkParams.startFlag = TRUE;
        Clock_create(clk0Fxn, 2, &clkParams, NULL);
#endif

    /* start scheduler, this never returns */
    BIOS_start();
    /* should never get here */
    return (0);
}

回复

使用道具 举报

36

主题

526

帖子

7569

积分

创龙

Rank: 8Rank: 8

积分
7569
发表于 2019-3-27 17:47:55 | 显示全部楼层
您好,
    具体细节需要您那边根据实际情况确定,提供部分资料供您参考排查。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2024-3-29 15:30 , Processed in 0.036222 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表