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.

GPIO Interrupt not happening

I am working on a DM814EVM from mistral.

I think I have the Hwi, GPIO interupts all setup correctly.

Not sure if I have setup the clocks correctly.

I can poll and see my injected signal.

Can someone review the following code?

Thanks,

Michael.

/*Sanitised header file*/

#define WR_MEM_32(addr, data)    *(unsigned int*)(addr) =(unsigned int)(data)
#define RD_MEM_32(addr) 	  	 *(unsigned int*)(addr)
/* KNOWN MEMORY ADDRESSES */

#define GPIO_BASE 0x08032000
#define GPIO_SYSCONFIG (GPIO_BASE + 0x10)
#define GPIO_IRQSTATUS_0 (GPIO_BASE + 0x2C)
#define GPIO_IRQSTATUS_SET_0 (GPIO_BASE + 0x34)
#define GPIO_RISINGDETECT (GPIO_BASE + 0x148)
#define GPIO_DATAIN (GPIO_BASE + 0x138)


#define PRCM_BASE 0x08180000
#define CM_ALWON_GPIO_0_CLKCTRL (PRCM_BASE + 0x155C)

  • #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Timestamp.h>
    #include <xdc/runtime/Types.h>
    #include <xdc/cfg/global.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/hal/Hwi.h>
    #include <ti/sysbios/hal/Timer.h>
    
    
    #include "Drivers.h"
    
    void DSP_Init(void);
    void hwiServiceGPIOINT0A(UArg arg0);
    void ServiceEOF(UArg arg0,UArg arg1 );
    
    Semaphore_Handle semEOF;
    
    
    Hwi_Handle hwiGPIO;
    Hwi_Params hwiParams;
    
    Task_Params taskParams;
    
    Error_Block eb;
    
    uint32_T numfilts = 0;
    uint32_T  numEOFs = 0;
    uint32_T  num29s = 0;
    UInt32 ticks,lastticks;
    float elapsed;
    
    
    void hwiServiceGPIOINT0A(UArg arg0 )
    {
    
    /*NOT GETTING HERE*/
    
    	Types_FreqHz freq;
    	Timestamp_getFreq(&freq);
    	uint32_T *pgpio_irqstatus_0 = (uint32_T*)(GPIO_IRQSTATUS_0);
    
    	ticks = (UInt32)Timestamp_get32();
    	elapsed = ((float)ticks - (float)lastticks)/(float)freq.lo;
    	numEOFs++;
    	lastticks = ticks;
    
    	/*Check the GPIO_IRQSTATUS_0 to see if pin 29 went high */
    	if(RD_MEM_32(GPIO_IRQSTATUS_0) & 0x20000000 > 0)
    	{
    		num29s++;
    	}
    	/*Release the interrupt */
    	RD_MEM_32(GPIO_IRQSTATUS_0,0x20000000);
    
    	Semaphore_post(semEOF);
    
    }
    
    
    void ServiceEOF(UArg arg0,UArg arg1 )
    {
    	UInt32 start_time;
    	UInt32 end_time;
    	Uint32 elapse_time;
    
    	for(;;)
    	{
    		/*Wait until HWI posts semaphore*/
    		Semaphore_pend(semEOF, BIOS_WAIT_FOREVER);
    		//		/* Start timer */
    		
    		//		GetInputs();
    		//		DoStuff();
    		//		WriteOutputs();
    		
    		
    
    	}
    }
    
    void main()
    {
    
    
    	DSP_Init();
    	for(;;);
    
    
    
    }
    
    void DSP_Init(void)
    {
    
    
    	uint32_T a;
    	Error_init(&eb);
    
    
    	semEOF = Semaphore_create(0, NULL, &eb);
    	if (semEOF == NULL)
    	{
    		System_abort("Semaphore for EOF create failed");
    	}
    
    
    	Error_init(&eb);
    	Hwi_Params_init(&hwiParams);
    	hwiParams.arg = 5;
    	hwiGPIO = Hwi_create(64, hwiServiceGPIOINT0A, &hwiParams, &eb); /*GPIOINT0A*/
    	if (hwiGPIO == NULL)
    	{
    		System_abort("Hwi create failed");
    	}
    
    	/* Task for image processing */
    	Task_Params_init(&taskParams);
    	taskParams.priority = 1;
    	taskParams.stackSize = 4000;
    	Task_create (ServiceEOF, &taskParams, NULL);
    
    	/* Setup GPIO */
    	/* setup GPIO_SYSCONFIG: No idle, (0x8) */
    	WR_MEM_32(GPIO_SYSCONFIG, 0x8);
    	/* Interrupts for the GPIO channel must be enabled in the GPIO_IRQSTATUS_SET_0 */
    	/* Enable interrupt on GPIO_0_29 (0x20000000) */
    	WR_MEM_32(GPIO_IRQSTATUS_SET_0, 0xFFFFFFFF);//0x20000000;
    	/* The expected event(s) on input GPIO to trigger the interrupt request has to be selected in the
    	 * GPIO_RISINGDETECT(0x20000000) */
    	WR_MEM_32(GPIO_RISINGDETECT, 0xFFFFFFFF);//0x20000000;
    
    	a = RD_MEM_32(CM_ALWON_GPIO_0_CLKCTRL);
    	WR_MEM_32(CM_ALWON_GPIO_0_CLKCTRL,0x102);
    //	for(;;)
    //	{
    //		a = RD_MEM_32(GPIO_DATAIN); //using this to poll to check if I can see the signal (I can)
    //	}
    	WR_MEM_32(GPIO_IRQSTATUS_0,0xFFFFFFFF); // Dont think I need this, but I was trying to get the interrupt.
    	Hwi_enableInterrupt(64); // Dont think I need this, but I was trying to get the interrupt.
    	a = Hwi_enable();// Dont think I need this, but I was trying to get the interrupt.
    
    	BIOS_start();
    
    }
    

  • Have you download and try the GPIO sample code from MIstral at:  http://www.mistralsolutions.com/pes-support/support-downloads/tmdxevm8148.html#?

    BR,

    Viet

  • Hi Michael,

    In your dot h file "0160.Drivers.h.txt" I am observing that base addresses are wrong.

    Instance "0" GPIO_BASE is 0x48032000 but not 0x08032000
    And PRCM_BASE 0x48180000 but not 0x08180000

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • I believe that that base address is for the ARM. This code is running on the DSP, so I think the base address is correct.

    Thanks.