嵌入式开发者社区
标题:
AM5728的DSP核,GPIO中断响应滞后的问题(代码基于SYSBIO)
[打印本页]
作者:
xiongxinjian
时间:
2019-3-27 14:55
标题:
AM5728的DSP核,GPIO中断响应滞后的问题(代码基于SYSBIO)
大家好!
我用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);
}
作者:
梁淑怡-Tronlong
时间:
2019-3-27 17:47
您好,
具体细节需要您那边根据实际情况确定,提供部分资料供您参考排查。
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4